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

相关推荐
二喵❥(^_-)1 天前
接口测试流程的三个核心环节
开发语言·lua
我的xiaodoujiao2 天前
Django 基础知识详细图文教程 13-Django 模型定义与使用 3
数据库·后端·python·测试工具·oracle·django
Felven4 天前
stress-ng 与 fio 性能测试工具使用指南
linux·测试工具·fio·stress-ng
H_unique4 天前
Chat2Excel:接口自动化测试
python·测试工具·自动化
Sarapines Programmer5 天前
【Wireshark】安装与使用指南
网络·测试工具·wireshark
念越5 天前
接口自动化测试从入门到实战:接口用例设计、Requests、Pytest、YAML、JSON Schema 与 Allure 报告
python·测试工具·自动化·json·pytest
ysu_03147 天前
Postman接口调试实战指南-从HTTP请求到环境变量-Collection与自动化测试
网络·网络协议·测试工具·http·api·postman·可用性测试
小师兄吃牛肉7 天前
C++ 与 Lua 的协程交互:从原理到实战
c++·lua·交互
喜欢的名字被抢了7 天前
09-Redis 进阶原理篇:单线程、多线程、过期、LRU-LFU、Fork 与 Lua
数据库·redis·lua
ZhangJun958 天前
从零写一个类鲁大师的硬件检测小工具,软件附上,可直接使用
windows·测试工具·电脑·笔记本电脑·硬件架构