WIP, próbuje zrozumieć po co istnieje frontend
This commit is contained in:
@@ -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() {
|
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();
|
const data = await response.json();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Error");
|
throw new Error(response.toString());
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNoticeById(noticeId) {
|
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();
|
const data = await response.json();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -18,3 +18,17 @@ export async function getNoticeById(noticeId) {
|
|||||||
}
|
}
|
||||||
return data;
|
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();
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ export default function Notices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
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 (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user