From 42408816f4a158a980d5efe688bb824878cebba2 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Mon, 9 Jun 2025 23:26:38 +0200 Subject: [PATCH 1/2] =?UTF-8?q?zdj=C4=99cia=20naprawione=20po=20raz=20drug?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArtisanConnect/api/notices.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ArtisanConnect/api/notices.jsx b/ArtisanConnect/api/notices.jsx index b6aa585..ef23166 100644 --- a/ArtisanConnect/api/notices.jsx +++ b/ArtisanConnect/api/notices.jsx @@ -73,9 +73,7 @@ export async function getAllImagesByNoticeId(noticeId) { const { token } = useAuthStore.getState(); const headers = token ? { Authorization: `Bearer ${token}` } : {}; try { - const listResponse = await axios.get(`${API_URL}/images/list/${noticeId}`, { - headers: headers, - }); + const listResponse = await axios.get(`${API_URL}/images/list/${noticeId}`, {headers: headers}); if (listResponse.data && listResponse.data.length > 0) { return listResponse.data.map((imageName) => ({ @@ -112,7 +110,7 @@ export const uploadImage = async (noticeId, imageUri) => { const type = match ? `image/${match[1]}` : "image/jpeg"; formData.append("file", { - uri: imageUri.uri, + uri: imageUri, name: filename, type: type, }); @@ -129,6 +127,7 @@ export const uploadImage = async (noticeId, imageUri) => { return response.data; } catch (error) { console.log("imageURI:", imageUri); + console.error( "Error uploading image:", error.response.data, From 301687a609ca8c224a911033de54c669695973a6 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Mon, 9 Jun 2025 23:36:48 +0200 Subject: [PATCH 2/2] headersy --- ArtisanConnect/api/notices.jsx | 2 +- ArtisanConnect/api/wishlist.jsx | 4 ++-- ArtisanConnect/store/authStore.jsx | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ArtisanConnect/api/notices.jsx b/ArtisanConnect/api/notices.jsx index ef23166..01dbc3e 100644 --- a/ArtisanConnect/api/notices.jsx +++ b/ArtisanConnect/api/notices.jsx @@ -144,7 +144,7 @@ export const deleteNotice = async (noticeId) => { try { const response = await axios.delete( `${API_URL}/notices/delete/${noticeId}`, - { headers } + { headers: headers } ); return response.data; } catch (error) { diff --git a/ArtisanConnect/api/wishlist.jsx b/ArtisanConnect/api/wishlist.jsx index ce59688..80b2b4d 100644 --- a/ArtisanConnect/api/wishlist.jsx +++ b/ArtisanConnect/api/wishlist.jsx @@ -12,7 +12,7 @@ export async function toggleNoticeStatus(noticeId) { `${API_URL}/toggle/${noticeId}`, {}, { - headers, + headers: headers, } ); return response.data; @@ -27,7 +27,7 @@ export async function getWishlist() { const headers = token ? { Authorization: `Bearer ${token}` } : {}; try { - const response = await axios.get(`${API_URL}/`, { headers }); + const response = await axios.get(`${API_URL}/`, { headers: headers }); return response.data; } catch (error) { console.error("Error fetching wishlist:", error); diff --git a/ArtisanConnect/store/authStore.jsx b/ArtisanConnect/store/authStore.jsx index 5ad2d40..17f4195 100644 --- a/ArtisanConnect/store/authStore.jsx +++ b/ArtisanConnect/store/authStore.jsx @@ -19,6 +19,7 @@ export const useAuthStore = create( (error.response && error.response.status === 401) || error.response.status === 403 ) { + console.warn(error.response.data); set({ user_id: null, token: null, isLoading: false }); delete axios.defaults.headers.common["Authorization"]; router.replace("/login");