Cleaned up the promise mapping in apiRequestWithHeaders

This commit is contained in:
Natty 2023-10-31 18:52:14 +01:00
parent edd46a4a1b
commit ff0f81d475
No known key found for this signature in database
GPG key ID: BF6CB659ADEE60EC

View file

@ -18,11 +18,7 @@ async function apiRequestWithHeaders(url, options = null) {
throw new Error(`Error fetching ${url}: ${response.status} ${response.statusText}`);
})
.then(response => new Promise((resolve, reject) => {
response.json()
.then(rbody => resolve({headers: response.headers, body: rbody}))
.catch(error => reject(error))
}))
.then(async response => ({ headers: response.headers, body: await response.json() }))
.catch(error => {
console.error(`Error fetching ${url}: ${error}`);
return null;