Skip to content

Commit

Permalink
fix: parse error message properly for manual installs
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Dec 11, 2023
1 parent a00f1e8 commit 581cc18
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ class Api {
method,
body,
credentials: 'include',
}).then((res) => {
}).then(async (res) => {
if (res.status < 200 || res.status >= 300) {
throw new Error(res.statusText)
try {
const errorBody = await res.json()
throw errorBody
} catch (_) {
throw new Error(res.statusText)
}
}
return res
})
Expand Down

0 comments on commit 581cc18

Please sign in to comment.