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

相关推荐
xie881018021 小时前
长表格跨页重复表头:排版上的做法
测试工具
老孟说禅7 小时前
测试工具示波器的使用
测试工具
步行cgn1 天前
为什么使用接口测试工具?
测试工具
P1Browser1 天前
Puppeteer 与 Selenium 技术对比:多账号自动化管理如何做环境隔离?
selenium·测试工具·自动化
weihubeats2 天前
10 MB 的 Postman 替代品,启动不到 1 秒
测试工具·postman
笨鸟先飞的橘猫2 天前
skynet热更新实现问题与排错记录
学习·lua·skynet
Meta Luo5 天前
UI 自动化测试中的等待、超时和异步加载怎么处理
功能测试·测试工具·ui·回归·自动化
yeflx5 天前
Ubuntu22.04下通过Wireshark抓取相机IP
tcp/ip·测试工具·wireshark
总线通信小百科5 天前
100BASE-T1媒体转换器选型:接口、主从模式与供电怎么判断?
经验分享·测试工具
测试开发技术5 天前
AI时代我们要如何玩抓包测试:Reqable + AI Agent
软件测试·人工智能·测试工具·接口测试·agent·抓包