From b1bb730c7d97727ee7c903d43c76adbf3b8bff40 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 9 Aug 2023 17:01:38 +0100 Subject: [PATCH] made file name in upload not to have spaces --- src/components/UploadProduct/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/UploadProduct/index.jsx b/src/components/UploadProduct/index.jsx index 67cd95b..c569911 100644 --- a/src/components/UploadProduct/index.jsx +++ b/src/components/UploadProduct/index.jsx @@ -88,7 +88,7 @@ export default function UploadProduct() { // most importend imgRead.readAsDataURL(e.target.files[0]); } - if (file.length) { + if (file?.length) { if (file[0].name) { setSelectedFile(file?.[0].name); setImgDetails(file?.[0]) @@ -143,7 +143,7 @@ export default function UploadProduct() { } let reqData = { // PAYLOAD FOR API CALL - file_name: selectedFile, + file_name: selectedFile.replace(/ /gi, ""), file_size: imgDetails.size, file_type: imgDetails.type, file_data: img, @@ -158,6 +158,7 @@ export default function UploadProduct() { //API CALL TO UPLOAD COMES HERE setRequestStatus({loading: true, status: null, message: ''}) // SETS REQUEST LOADING TRUE apiCall.sendFiles(reqData).then(res=>{ + console.log('TESTING', res) if(res.status != 200 || res.data.internal_return < 0){ return setRequestStatus({loading: false, status: false, message: 'Something went wrong, try again'}) }