vlki / refresh-fetch

Wrapper around fetch capable of graceful authentication token refreshing.
MIT License
84 stars 12 forks source link

fetchJSON - using "text()" method on response blocks body stream #12

Closed hornetDC closed 4 years ago

hornetDC commented 4 years ago

Hi. I wanted my fetchWithToken function to return Promise<Response> like regular fetch. When working with fetch, I usually return response as response.json(), but request returned by configureRefreshFetch gave me an error: Failed to execute 'json' on 'Response': body stream is locked. https://stackoverflow.com/q/53511974

This can be solved by cloning response in getResponseBody func before using text().

vlki commented 4 years ago

Hey, yeah, good point. Changed and released as v0.7.0