fix request functionr return values

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-03-01 00:01:56 +00:00
parent 7f3bbbbff2
commit d7e835b3c5

View File

@ -138,15 +138,9 @@ export async function requestAPI (path, method, body = null) {
async function request (url, content) {
let response = await fetch(url, content)
.then((response) => {
if (!response.ok) {
throw new ResponseError(`recieved response status code ${response.status}`);
}
return response;
})
.catch((error) => {
if (error instanceof ResponseError) {
throw error;
}
throw new NetworkError(error);
});