Compare commits
3 Commits
a527d00e1d
...
366ea4ada3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
366ea4ada3 | ||
| 301687a609 | |||
| 42408816f4 |
@@ -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,
|
||||
@@ -145,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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user