From ff0f81d475dd66374020a2c6f9b224ca1a66fe20 Mon Sep 17 00:00:00 2001 From: Natty Date: Tue, 31 Oct 2023 18:52:14 +0100 Subject: [PATCH] Cleaned up the promise mapping in apiRequestWithHeaders --- create-circle.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/create-circle.js b/create-circle.js index 361a623..648d2ef 100644 --- a/create-circle.js +++ b/create-circle.js @@ -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;