fixed getFileList when the response isn't OK
This commit is contained in:
parent
c8bf3101aa
commit
7eb7590f06
|
@ -359,8 +359,11 @@ export function downloadFile(id, keychain, onprogress) {
|
||||||
export async function getFileList(bearerToken) {
|
export async function getFileList(bearerToken) {
|
||||||
const headers = new Headers({ Authorization: `Bearer ${bearerToken}` });
|
const headers = new Headers({ Authorization: `Bearer ${bearerToken}` });
|
||||||
const response = await fetch('/api/filelist', { headers });
|
const response = await fetch('/api/filelist', { headers });
|
||||||
|
if (response.ok) {
|
||||||
return response.body; // stream
|
return response.body; // stream
|
||||||
}
|
}
|
||||||
|
throw new Error(response.status);
|
||||||
|
}
|
||||||
|
|
||||||
export async function setFileList(bearerToken, data) {
|
export async function setFileList(bearerToken, data) {
|
||||||
const headers = new Headers({ Authorization: `Bearer ${bearerToken}` });
|
const headers = new Headers({ Authorization: `Bearer ${bearerToken}` });
|
||||||
|
@ -369,5 +372,5 @@ export async function setFileList(bearerToken, data) {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data
|
body: data
|
||||||
});
|
});
|
||||||
return response.status === 200;
|
return response.ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue