You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently implementing refresh token logic using response interceptor and I want to use the client to retry the request but this will cause the body to be parsed twice in case of error response.
asyncfunctionrefreshTokenInterceptor(response: Response,request: Request,options: RequestOptions<false>&{_retry?: boolean},{if(response.status!==401)returnresponse;// Refresh token ...// this .request() call will call .text() on the response// The original .request() call before token was refreshed will call .text() after below request is resolved, // throwing an error because body cant be read twicereturnoptions.client.request({...options,parseAs: "stream",_retry: true});}
Passing parseAs: stream circumvents the parsing of the body on success responses but it does not work on error responses.
parseAs should also be applied when parsing error responses.
Description
Currently all error responses are expected to be json:
https://github.com/hey-api/openapi-ts/blob/ea24bca1ef3e30e5b6543d4b5b791ca9fb4fd322/packages/client-fetch/src/index.ts#L125C1-L132C1
I am currently implementing refresh token logic using response interceptor and I want to use the client to retry the request but this will cause the body to be parsed twice in case of error response.
Passing
parseAs: stream
circumvents the parsing of the body on success responses but it does not work on error responses.parseAs
should also be applied when parsing error responses.Package versions are:
The text was updated successfully, but these errors were encountered: