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
Well I may have spent too long staring at code and fried my brain, I see now !~tmp.indexOf('application/json') would be true in my example, so that flow result is incorrect. 🤦
The response is still inconsistent, but in a way that I can handle:
The node version resolves the promise with response.data being the fully realized response body XML string.
Whereas the fetch version simply resolves the promise with response, aka the response body is not yet fully realized.
My resolution to this was, in my code, to simply do:
I don't know what the "Right Thing" to do here would be, since the goal isn't full strict isomorphism between the two, but since you're waiting for the body stream to be realized in the Node version, it seems like it might be appropriate to do the same in the fetch version? Something like this, probably:
Consider a request to a server that successfully returns XML data (aka anything that is not JSON).
In the node version we have this flow:
out
as the concatenated data stream stringcontent-type
does not includeapplication/json
so...data
property is set to theout
(aka the response body realized)response.data
is the response body XML string)However, in the fetch version we have this flow:
content-type
does not includeapplication/json
so...fetch.text()
as JSONfetch.text()
string is not available on the responseThe text was updated successfully, but these errors were encountered: