WIP, próbuje zrozumieć po co istnieje frontend

This commit is contained in:
2025-04-29 14:30:57 +02:00
parent a05c1508e4
commit 580715947d
2 changed files with 20 additions and 5 deletions

View File

@@ -1,16 +1,16 @@
const API_URL = "https://testowe.zikor.pl/api/v1/notices/";
const API_URL = "http://10.224.1.86:8080/api/v1/notices";
export async function listNotices() {
const response = await fetch(`${API_URL}get/all`);
const response = await fetch(`${API_URL}/get/all`);
const data = await response.json();
if (!response.ok) {
throw new Error("Error");
throw new Error(response.toString());
}
return data;
}
export async function getNoticeById(noticeId) {
const response = await fetch(`${API_URL}get/${noticeId}`);
const response = await fetch(`${API_URL}/get/${noticeId}`);
const data = await response.json();
if (!response.ok) {
@@ -18,3 +18,17 @@ export async function getNoticeById(noticeId) {
}
return data;
}
export async function getImagesByNoticeId(noticeId) {
const response = await fetch(`http://10.224.1.86:8080/api/v1/images/list/${noticeId}`);
if (!response.ok) {
throw new Error(response.toString());
}
const data = await response.json();
const Image = await fetch(`http://10.224.1.86:8080/api/v1/images/get/${data.first}`);
return Image.blob();
}

View File

@@ -14,7 +14,8 @@ export default function Notices() {
}
if (error) {
return <Text>Błąd, spróbuj ponownie póżniej</Text>;
console.log(error.message);
return <Text>Nie udało sie pobrać listy. {error.message}</Text>;
}
return (