Skip to content

Commit

Permalink
fix: fix browser error parsing response body with status 204
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Jun 20, 2024
1 parent d1b40fa commit 4e80b29
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@semantic-release/git": "^10.0.1",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.5",
"@types/node": "^20.14.6",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"jest": "^29.7.0",
Expand Down
72 changes: 36 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const fetchURL = async (url: URL, requestOptions: FetchRequestOptions, cl
if (interceptors?.rawReader?.onFailure) await interceptors.rawReader.onFailure(response)
}

const responseBody = response.body ? await response.json()
const responseBody = (response.body && (response.status !== 204)) ? await response.json()
.then(json => { debug('response: %O', json); return json })
.catch((err: Error) => {
debug('error: %s', err.message)
Expand Down

0 comments on commit 4e80b29

Please sign in to comment.