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

相关推荐
se-tester2 天前
JMeter、Postman 和 SoapUI 在做接口测试上的优势和缺点
测试工具·jmeter·接口测试·postman·soapui
xixi09242 天前
selenium IDE——command
selenium·测试工具
xixi09242 天前
selenium IDE安装使用教程
ide·selenium·测试工具
Wpa.wk2 天前
har文件转为接口自动化测试用例
运维·测试工具·自动化·测试用例·接口自动化
Wpa.wk2 天前
ubuntu22桌面版安装
经验分享·测试工具
脑花儿3 天前
Dify平台聊天助手 API调用案例
api·postman·dify
007张三丰3 天前
软件测试专栏(6/20):Selenium从0到1实战指南:元素定位、等待机制与框架封装
selenium·测试工具
测试老哥3 天前
如何使用Postman做接口测试?
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
安全不再安全3 天前
某驱动任意读漏洞分析 - 可用于游戏内存数据读取
c语言·测试工具·安全·游戏·网络安全