瀏覽代碼

封装文件上传

Lijy 1 年之前
父節點
當前提交
dc8699c20a
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/request.ts

+ 14 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/request.ts

@@ -67,3 +67,17 @@ export async function post(url: string, data?: any): Promise<any> {
       throw error;
     });
 }
+
+// 封装文件上传请求
+export async function uploadFile(url: string, data?: any): Promise<any> {
+  return instance
+    .post(url, data, {
+      headers: {
+        "Content-type": "multipart/form-data",
+      },
+    })
+    .then((response) => response.data)
+    .catch((error) => {
+      throw error;
+    });
+}