Skip to content

Commit

Permalink
fix: processing response success handlers in error case
Browse files Browse the repository at this point in the history
Fixes an issue with response success handlers where handlers were executed even if the network response had an error status code.
  • Loading branch information
kleinfreund committed Nov 25, 2023
1 parent f4a1e06 commit 92567fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/retrieve.js

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

8 changes: 4 additions & 4 deletions src/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ export async function retrieve(config: RetrieveConfig): Promise<RetrieveResponse

let retrieveResponse = await createRetrieveResponse(response)

for (const responseSuccessHandler of config.responseSuccessHandlers ?? []) {
retrieveResponse = await responseSuccessHandler(retrieveResponse)
}

if (retrieveResponse.response.ok) {
for (const responseSuccessHandler of config.responseSuccessHandlers ?? []) {
retrieveResponse = await responseSuccessHandler(retrieveResponse)
}

return retrieveResponse
}

Expand Down

0 comments on commit 92567fb

Please sign in to comment.