init add Notice

This commit is contained in:
Patryk
2025-04-26 00:43:45 +02:00
parent ada1fa40db
commit ba07581f31
2 changed files with 106 additions and 20 deletions

View File

@@ -1,20 +1,35 @@
const API_URL = "https://testowe.zikor.pl/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("Error");
}
return data;
const response = await fetch(`${API_URL}get/all`);
const data = await response.json();
if (!response.ok) {
throw new Error("Error");
}
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) {
throw new Error("Error");
}
return data;
const data = await response.json();
if (!response.ok) {
throw new Error("Error");
}
return data;
}
export async function createNotice(notice) {
console.log("Notice created", notice);
// const response = await fetch(`${API_URL}add`, {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify(notice),
// });
// console.log("Response", response);
// if (!response.ok) {
// throw new Error("Error");
// }
}