From 599c4a222727273632b8427cc42a4f2130fc9954 Mon Sep 17 00:00:00 2001 From: Do-hyun Ko Date: Wed, 8 Jan 2025 20:57:11 +0900 Subject: [PATCH] :children_crossing: Prevent redundant image upload api call --- src/api/image/image.ts | 2 +- src/app/[lng]/write/handle-notice-submit.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/image/image.ts b/src/api/image/image.ts index 1fe7b63c..d34824d9 100644 --- a/src/api/image/image.ts +++ b/src/api/image/image.ts @@ -3,6 +3,6 @@ import { ziggleApi } from '..'; export const uploadImages = async (images: File[]) => { const fd = new FormData(); images.forEach((image) => fd.append('images', image)); - const { data } = await ziggleApi.post('/image/upload', fd); + const { data } = await ziggleApi.post('/image/upload', fd); return data; }; diff --git a/src/app/[lng]/write/handle-notice-submit.ts b/src/app/[lng]/write/handle-notice-submit.ts index 0afbc674..b02ef013 100644 --- a/src/app/[lng]/write/handle-notice-submit.ts +++ b/src/app/[lng]/write/handle-notice-submit.ts @@ -182,7 +182,8 @@ const handleNoticeSubmit = async ({ const tagIds: number[] | undefined = await handleTagSubmit(tags, t); if (!tagIds) return; - const imageKeys = await uploadImages(images).catch(() => null); + const imageKeys = + images.length > 0 ? await uploadImages(images).catch(() => null) : []; if (!imageKeys) { Swal.fire({ text: t('write.alerts.submitFail'),