34 lines
908 B
JavaScript
34 lines
908 B
JavaScript
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 data = await response.json();
|
|
if (!response.ok) {
|
|
throw new Error(response.toString());
|
|
}
|
|
return data;
|
|
}
|
|
|
|
export async function getNoticeById(noticeId) {
|
|
const response = await fetch(`${API_URL}/get/${noticeId}`);
|
|
|
|
const data = await response.json();
|
|
if (!response.ok) {
|
|
throw new Error("Error");
|
|
}
|
|
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();
|
|
} |