Skip to content

Commit

Permalink
Add await for res.json()
Browse files Browse the repository at this point in the history
  • Loading branch information
timursevimli committed May 1, 2024
1 parent 67307d8 commit f46d5c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const httpApiCall = async (url, { method = 'POST', headers = {}, body }) => {
const options = { method, body, headers: custom };
return await fetch(url, options).then(async (res) => {
const code = res.status;
if (code === 200) return res.json();
if (code === 200) return await res.json();
await res.body.cancel();
const dest = `for ${method} ${url}`;
throw new Error(`HTTP status code ${code} ${dest}`);
Expand Down

0 comments on commit f46d5c4

Please sign in to comment.