Skip to content

Commit

Permalink
fix: removed clone calls from reponse to prevent crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Zayne committed Jun 19, 2024
1 parent c0a9d43 commit dfbadb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-gifts-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zayne-labs/callapi": patch
---

fix: removed clone calls from reponse to prevent crashing
8 changes: 4 additions & 4 deletions src/createFetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ const createFetchClient = <
);

await options.onResponse?.({
response: { ...response.clone(), data: successData },
response: { ...response, data: successData },
request: requestInit,
options,
});

return resolveSuccessResult<CallApiResult>({ successData, response: response.clone(), options });
return resolveSuccessResult<CallApiResult>({ successData, response, options });

// == Exhaustive Error handling
} catch (error) {
Expand Down Expand Up @@ -188,14 +188,14 @@ const createFetchClient = <
const { errorData, ...response } = error.response;

await options.onResponseError?.({
response: { ...response.clone(), errorData },
response: { ...response, errorData },
request: requestInit,
options,
});

return resolveErrorResult({
errorData,
response: response.clone(),
response,
message: (errorData as PossibleErrorObject)?.message,
});
}
Expand Down

0 comments on commit dfbadb2

Please sign in to comment.