Fix getApi error handling

This commit is contained in:
Fred Boniface 2023-04-30 21:29:51 +01:00
parent ab452d985c
commit 1d365ea374
1 changed files with 4 additions and 4 deletions

View File

@ -151,17 +151,17 @@ async function getApi(path,auth = false) {
log(`resp.status: ${resp.status}`)
log(`resp.json: ${json}`)
if (resp.status != 200) {
log(`lib.main: getApi: Response status: ${resp.status}`)
return resp.status
}
if (!resp.ok) {
log(`lib.main: getApi: Fetch error`)
return false
}
if (json === "[]") {
return 'empty'
}
return json;
} catch(err) {
return false
log(`lib.main: getApi: Caught fetch error. Status: ${resp.status}`)
return resp.status
}
}