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

相关推荐
加油,旭杏2 小时前
【Lua语言】Lua语言快速入门
开发语言·lua
2401_897930062 天前
Selenium 入门介绍
selenium·测试工具
雨中夜归人2 天前
自动化测试工具playwright中文文档-------14.Chrome 插件
python·测试工具·自动化·pytest·playwright
SoFlu软件机器人2 天前
JVM 调优不再难:AI 工具自动生成内存优化方案
jvm·测试工具·压力测试
network_tester2 天前
是德科技E5080B网络分析仪深度评测:5G/车载雷达测试实战指南
网络·科技·测试工具·5g·硬件架构·信号处理·射频工程
码到成功>_<3 天前
postman使用技巧
测试工具·lua·postman
进修的小白~3 天前
接口测试(get请求方法)-----------实战演练
测试工具·postman
晓13133 天前
第三章 爬虫提速、selenium模块、requests模块进阶(终)
爬虫·python·selenium·测试工具·http
King.6244 天前
SQL2API 核心理念:如何重构数据服务交付范式
大数据·开发语言·数据库·人工智能·sql·lua