new method for pulling of all images
This commit is contained in:
@@ -65,6 +65,27 @@ export async function getImageByNoticeId(noticeId) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllImagesByNoticeId(noticeId) {
|
||||
try {
|
||||
const listResponse = await axios.get(`${API_URL}/images/list/${noticeId}`);
|
||||
|
||||
if (listResponse.data && listResponse.data.length > 0) {
|
||||
const imageUrls = listResponse.data.map(imageName =>
|
||||
`${API_URL}/images/get/${imageName}`
|
||||
);
|
||||
|
||||
console.log(`Pobrano ${imageUrls.length} zdjęć dla ogłoszenia o id: ${noticeId}`);
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
console.log(`Brak zdjęć dla ogłoszenia o id: ${noticeId}`);
|
||||
return ["https://http.cat/404.jpg"];
|
||||
} catch (err) {
|
||||
console.log(`Błąd podczas pobierania listy zdjęć dla ogłoszenia o id: ${noticeId}`, err);
|
||||
return ["https://http.cat/404.jpg"];
|
||||
}
|
||||
}
|
||||
|
||||
export const uploadImage = async (noticeId, imageUri) => {
|
||||
console.log("Started upload image");
|
||||
console.log(imageUri);
|
||||
|
||||
Reference in New Issue
Block a user