fix request functionr return values
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
7f3bbbbff2
commit
d7e835b3c5
@ -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);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user