zdjęcia pobierają się na głównej stronie + naprawiono kilka innych bugów.
takich jak wyświetlanie "Moich ogłoszeń nie dla poprawnego id etc."
This commit is contained in:
@@ -8,7 +8,7 @@ export async function listCategories() {
|
||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/vars/categories`, { headers });
|
||||
const response = await axios.get(`${API_URL}/vars/categories`, { headers: headers });
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.error("Nie udało się pobrać listy kategorii.", err.response.status);
|
||||
|
||||
@@ -33,12 +33,10 @@ export async function getNoticeById(noticeId) {
|
||||
}
|
||||
|
||||
export async function createNotice(notice) {
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||
try {
|
||||
const response = await axios.post(`${API_URL}/notices/add`, notice, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
const response = await axios.post(`${API_URL}/notices/add`, notice, {headers: headers});
|
||||
|
||||
if (response.data.noticeId !== null) {
|
||||
for (const imageUri of notice.image) {
|
||||
@@ -73,27 +71,26 @@ 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,
|
||||
});
|
||||
const listResponse = await axios.get(`${API_URL}/images/list/${noticeId}`, {headers: headers});
|
||||
|
||||
if (listResponse.data && listResponse.data.length > 0) {
|
||||
return listResponse.data.map(
|
||||
(imageName) => `${API_URL}/images/get/${imageName}`
|
||||
);
|
||||
return listResponse.data.map((imageName) => ({
|
||||
uri: `${API_URL}/images/get/${imageName}`,
|
||||
headers: headers,
|
||||
}));
|
||||
}
|
||||
|
||||
return ["https://http.cat/404.jpg"];
|
||||
return [{ uri: "https://http.cat/404.jpg" }];
|
||||
} catch (err) {
|
||||
if (err.response.status === 404) {
|
||||
// console.info(`Ogłoszenie o id: ${noticeId} nie posiada zdjęć.`);
|
||||
return ["https://http.cat/404.jpg"];
|
||||
return [{ uri: "https://http.cat/404.jpg" }];
|
||||
}
|
||||
console.warn(
|
||||
`Nie udało się pobrać listy zdjęć dla ogłoszenia o id: ${noticeId}`,
|
||||
err
|
||||
);
|
||||
return ["https://http.cat/404.jpg"];
|
||||
return [{ uri: "https://http.cat/404.jpg" }];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import axios from "axios";
|
||||
import { useAuthStore } from "@/store/authStore";
|
||||
// import FormData from 'form-data'
|
||||
|
||||
const API_URL = "https://hopp.zikor.pl/api/v1/wishlist";
|
||||
|
||||
@@ -36,3 +35,4 @@ export async function getWishlist() {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
``
|
||||
Reference in New Issue
Block a user