-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read json from multiple interceptors #48
Comments
Interceptors are chained such that the resolution value of one is propagated to the next. I think altering the data passed to a downstream interceptor would be unexpected. Would this be solved simply by cloning the response before reading its body? |
Or response.json(true) returns a clone |
Any thoughts on how to resolve this? |
Response bodies can only be read once, so you just need to clone the response if you want to read it multiple times. |
Ok, so we'll just close this then :) |
If multiple interceptors are installed in the fetch client, only one of them can call response.json(). The second one to call causes an "already read" exception. I suppose that makes some sense from a stream reading perspective, but it doesn't make sense if multiple interceptors are allowed. Obviously, it would not be uncommon to want to read at least part of the response in both places.
Maybe a
configure
option for caching the json in the client for mulitple access would be a solution?The text was updated successfully, but these errors were encountered: