fetch使用put请求提交文件,postman使用put请求提交文件

javascript 复制代码
import { createFetch } from "@vueuse/core";
       


         // 上传
        const useMyFetch = createFetch({
          options: {
            async beforeFetch({ options }) {
              options.method = "PUT";
              options.headers = {
                ...options.headers,
                "Content-Type": req.file.type
              };
              return { options };
            }
          }
        });
        const { error } = await useMyFetch(host).put(req.file).text();

        if (error.value) {
          ElMessage.error("文件上传失败");
          item.error = error.value.message;
          emit("error", item);
          return reject(error);
        }

人工智能学习网站

https://chat.xutongbao.top

相关推荐
一点事9 小时前
用postman,如何调用webservice接口?
测试工具·postman
咨询QQ6882388610 小时前
非线性悬架建模与UKF状态估计:Matlab/Simulink源码与详细建模说明
postman
程序员杰哥13 小时前
python+requests接口自动化测试
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
彼岸花@开14 小时前
postman配置jdk自签证书的双向认证功能
jdk·postman
小雨下雨的雨14 小时前
第5篇:Redis事务与Lua脚本
redis·junit·lua
测试人社区—841614 小时前
Postman API测试指南
人工智能·git·测试工具·自动化·bug·postman
天才测试猿16 小时前
自动化测试实践总结
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
测试人社区—841616 小时前
Appium移动自动化测试:从入门到精通实战
人工智能·安全·appium·自动化·bug·postman
安然无虞17 小时前
性能测试·基础理论和指标
测试工具·jmeter·压力测试
月亮!18 小时前
量子计算遇上AI:下一代算力突破的关键节点
运维·网络·人工智能·python·测试工具·自动化·量子计算