-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Response body should be able to be read after fetching #1159
Comments
Question: why would you want to get Trying to understand the real-world usecase here to provide a good workaround. I’d like to not have to require everyone calling |
First of all, I do agree with you on this. However, I'd like to point out that my proposal doesn't require the end user to do anything differently, as the only difference will be the ability to process the body manually. My usecase (and I assume it's possible I'm not the only one) is to read the blob from the response body. As I stated earlier, trying to do this right now results in an error. Due to this, I had to rely on using the raw There is also a possibility someone needs to process the raw body stream or the It is indeed very convenient to assume that 99.9% of usecases will be about parsing JSON, but current implementation also robs the end user of the convenience to also cover the remaining 0.1% by hand if needed. Cloning the response before processing it on the side of the library would allow the end user the flexibility of a native fetch response while still providing all the convenience. UPD: edited the original issue to include the |
Could you give more specific detail why you’re trying to read a As you’re probably already aware, that error comes directly from the native fetch API. because we call I’m also not interested in not calling the fetch API’s built-in Anyways, all that said, I’d like to assume that your OpenAPI schema contains all the information needed to infer which response you want, so I’d love additional detail as to why you’d want a |
I believe you have misunderstood my intentions with the implementation a little. I'll try to be a bit more specific. Please, take a look: Raiondesu@92f0412
I understand this and I do agree with you, so this is not what I propose. My proposal involves simply cloning the response before calling
Besides that the details of my usecase are under an NDA, I believe that they will not be of any value to this discussion anyway, as I am certain that my proposal improves user-experience of the library in general when processing a response, rather than addressing a highly-specific usecase. P.S.
Sorry for the trouble, could you please reference where exactly the library does this? |
Thanks for providing more detail, and a great suggestion on implementation. I do think solving this is valuable, as it relates to #1123 and #1157. I’ve added a new
I apologize; it doesn’t! I was getting confused with some in-flight work / other conversations where we had talked about doing it. But it never ended up landing. But all that will change in the next release. |
This is fixed in |
Description
Currently, if one attempts to read a response body in any way (
.text()
/.blob()
/etc.) after fetching, they will be presented with the following error:Reproduction
json()
orblob()
in athen
block after the request:Expected result
I argue the user should expect the
response
property to contain a fully functional original response, with the ability to parse the body without any errors in any way should the need arise.Checklist
The text was updated successfully, but these errors were encountered: