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

相关推荐
Luminbox紫创测控16 小时前
太阳光模拟器在汽车智能玻璃的运用
测试工具·汽车
西瓜程序猿18 小时前
如何将纸质版礼薄转换为电子礼薄?可以使用记了么
测试工具·创业创新
123过去20 小时前
crunch使用教程
linux·测试工具·安全
123过去1 天前
samdump2使用教程
linux·测试工具·安全
测试19981 天前
使用Python自动化生成接口测试用例
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
lifewange2 天前
postman接口自动化如何进行参数化
数据库·自动化·postman
妖萌妹儿2 天前
postman怎么做参数化批量测试,测试不同输入组合
开发语言·javascript·postman
lifewange2 天前
Cypress是什么
测试工具
川石课堂软件测试2 天前
涨薪技术|Prometheus使用Recoding Rules优化性能
功能测试·测试工具·jmeter·mysql·面试·单元测试·prometheus