Adding catches
All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 29s
Music Collection CI Workflow / test (./frontend) (push) Successful in 35s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 50s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m51s
Music Collection CI Workflow / deploy (push) Successful in 26s

This commit is contained in:
Phill Pover 2025-04-07 04:42:16 +01:00
parent 46a44bf7f6
commit ea1108e49c

View File

@ -5,7 +5,10 @@ export async function getAlbums() {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -16,7 +19,10 @@ export async function getAlbum(id: number) {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -35,7 +41,10 @@ export async function createAlbum(formData: FormData) {
genre: genre, genre: genre,
}) })
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -57,8 +66,10 @@ export async function updateAlbum(formData: FormData) {
genre: genre, genre: genre,
}) })
}).then(response => { }).then(response => {
console.log(response.json()); if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -72,7 +83,10 @@ export async function deleteAlbum(id: number) {
id: id, id: id,
}) })
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -83,7 +97,10 @@ export async function getSongs() {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -94,7 +111,10 @@ export async function getSong(id: number) {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -115,7 +135,10 @@ export async function createSong(formData: FormData) {
trackNumber: trackNumber, trackNumber: trackNumber,
}) })
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -138,7 +161,10 @@ export async function updateSong(formData: FormData) {
trackNumber: trackNumber, trackNumber: trackNumber,
}) })
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -149,7 +175,10 @@ export async function deleteSong(id: number) {
method: "DELETE", method: "DELETE",
headers: { "Content-Type": "application/json" } headers: { "Content-Type": "application/json" }
}).then(response => { }).then(response => {
if (response.ok) {
return response.json(); return response.json();
}
return Promise.reject(response);
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });