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

相关推荐
源代码•宸12 分钟前
goframe框架签到系统项目开发(补签逻辑实现、编写Lua脚本实现断签提醒功能、简历示例)
数据库·后端·中间件·go·lua·跨域·refreshtoken
熊文豪1 小时前
Selenium 自动化测试入门指南
selenium·测试工具
食咗未1 小时前
Linux lrzsz文件传输工具的使用
linux·测试工具
唐古乌梁海1 小时前
Selenium元素定位不稳定
python·selenium·测试工具
@杨某1 小时前
selenium嵌入scrapy动态网页抓取
selenium·测试工具·scrapy
每天回答3个问题1 小时前
Lua 函数教程
开发语言·ue5·ue4·lua
废弃的小码农11 小时前
功能测试--Day01--Web项目测试
功能测试·测试工具
Dillon Dong16 小时前
网络通讯:Wireshark常用的报文过滤指令
网络·测试工具·wireshark
测试老哥20 小时前
2026最新的软件测试面试八股文(答案+文档)
自动化测试·软件测试·python·测试工具·面试·职场和发展·测试用例
BullSmall20 小时前
自动化测试开发规范
selenium·测试工具·appium·自动化