From 7bcdb26c4b70262afcd63c89291a5370a4d03748 Mon Sep 17 00:00:00 2001 From: Net Date: Wed, 28 Aug 2024 09:48:36 +0700 Subject: [PATCH] refactor: put File return data at succeed --- src/stores/customer/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stores/customer/index.ts b/src/stores/customer/index.ts index 5a816625..3abdf649 100644 --- a/src/stores/customer/index.ts +++ b/src/stores/customer/index.ts @@ -215,7 +215,7 @@ const useCustomerStore = defineStore('api-customer', () => { file: File; filename?: string; }) { - await api.put( + const res = await api.put( `/customer-branch/${opts.branchId}/attachment/${opts.filename || opts.file.name}`, opts.file, { @@ -223,6 +223,10 @@ const useCustomerStore = defineStore('api-customer', () => { onUploadProgress: (e) => console.log(e), }, ); + + if (res.status >= 400) return false; + + return true; } async function deleteAttachment(id: string, filename: string) {