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

相关推荐
123过去2 小时前
ike-scan使用教程
linux·测试工具
半个俗人2 小时前
07.postman newman生成测试报告
测试工具·postman
爱敲代码的菜菜14 小时前
【测试】自动化测试
css·selenium·测试工具·junit·自动化·xpath
liulilittle16 小时前
范围随机算法实现
开发语言·c++·算法·lua·c·js
123过去1 天前
wireshark使用教程
linux·网络·测试工具·wireshark
123过去1 天前
hexinject使用教程
linux·网络·测试工具
测试19981 天前
功能测试、自动化测试、性能测试的区别?
自动化测试·软件测试·python·功能测试·测试工具·性能测试·安全性测试
红黑色的圣西罗1 天前
Lua和C#交互探究记录
c#·lua·交互
爱敲代码的菜菜1 天前
【测试】Selenium
selenium·测试工具·xpath·webdriver·cssselector