diff --git a/ArtisanConnect/api/notices.jsx b/ArtisanConnect/api/notices.jsx index 1d198c2..b1700f1 100644 --- a/ArtisanConnect/api/notices.jsx +++ b/ArtisanConnect/api/notices.jsx @@ -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(); +} \ No newline at end of file diff --git a/ArtisanConnect/app/(tabs)/notices.jsx b/ArtisanConnect/app/(tabs)/notices.jsx index f93fd89..035fff0 100644 --- a/ArtisanConnect/app/(tabs)/notices.jsx +++ b/ArtisanConnect/app/(tabs)/notices.jsx @@ -14,7 +14,8 @@ export default function Notices() { } if (error) { - return Błąd, spróbuj ponownie póżniej; + console.log(error.message); + return Nie udało sie pobrać listy. {error.message}; } return (