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

相关推荐
zhengfei6115 小时前
渗透工具集——15款常见C2的框架
测试工具·安全
Dingdangr9 小时前
基于Python的火焰识别系统设计与实现(含论文、开题报告及答辩PPT)
java·python·测试工具·安全
少云清9 小时前
【接口测试】8_Postman _Postman测试报告
测试工具·postman
Wpa.wk10 小时前
自动化测试(java) - PO模式了解
java·开发语言·python·测试工具·自动化·po模式
疏狂难除11 小时前
windows上使用LLVM编译lua
开发语言·lua
Rover.x12 小时前
Wireshark抓包分析工具
网络·测试工具·wireshark
湫一刀1 天前
WireShark下载说明
网络·测试工具·wireshark
拽着尾巴的鱼儿1 天前
工具:Postman-CRUL 接口调用
测试工具·postman
love is sour1 天前
深入浅出 jmap:Java 内存分析的“显微镜“
java·开发语言·测试工具·性能优化
少云清1 天前
【接口测试】6_Postman _Postman关联
测试工具·postman