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

相关推荐
祉猷并茂,雯华若锦19 小时前
Selenium与Playwright元素定位终极对决
selenium·测试工具
小白学大数据1 天前
长周期爬虫的数据一致性:断点续爬 + 事务回滚保障采集质量
开发语言·爬虫·测试工具
小努蛋1 天前
linux编译openresty异常问题,lua_cjson.c:706:5: 错误: ‘for‘ 循环初始化声明只在 C99 或 C++ 模式下允许
开发语言·lua·openresty
小绫网络安全1 天前
Wireshark抓包完全入门教程:从零开始掌握网络分析
arm开发·测试工具·wireshark
梦想不只是梦与想2 天前
鸿蒙 测试工具:DevEco Testing(一)
测试工具·harmonyos·testing
我的xiaodoujiao3 天前
快速学习Python基础知识详细图文教程17--类型注解和断点调试
开发语言·python·学习·测试工具
rockey6273 天前
基于AScript的Lua脚本语言发布啦
c#·.net·lua·script·动态脚本
泽众云测试3 天前
泽众软件与日联科技达成合作,TestOne自动化测试平台助力搭建工业检测装备数字化品控防线
功能测试·测试工具·自动化
小小尚@3 天前
AE脚本-AE Actions v1.1.8 操作动作记录器
开发语言·前端·javascript·jupyter·postman