feat: show error toast if trying to download db on external db

This commit is contained in:
Jun Siang Cheah 2024-04-27 15:53:31 +01:00
parent e91a49c455
commit 47a33acfeb
4 changed files with 21 additions and 6 deletions

View file

@ -83,9 +83,9 @@ export const downloadDatabase = async (token: string) => {
Authorization: `Bearer ${token}`
}
})
.then((response) => {
.then(async (response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
throw await response.json();
}
return response.blob();
})
@ -100,7 +100,11 @@ export const downloadDatabase = async (token: string) => {
})
.catch((err) => {
console.log(err);
error = err;
error = err.detail;
return null;
});
if (error) {
throw error;
}
};