-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
react-native: res.body is null, only res.text is working #636
Comments
Same for me. The |
I'm having the same error as well. |
@slooker @jonaswindey You can make the change in the PR above & see if that fixes for you as well. It was the cause of my problems. |
This solved the problem for me. Nice work. :) |
Summary: `XMLHttpRequest.getResponseHeader` is case-insensitive, therefor the React-Native implementation needs to mimic this behavior as to not break libraries that are dependent on this. There is a corresponding issue in `superagent` but this is the root cause (ladjs/superagent#636). Closes facebook#1138 Github Author: Ryan Pastorelle <rpastorelle@yahoo.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
I'm having this issue as well using the latest version of react-native and superagent. When I do However, there is no problem when I do a request to https://api.github.com/users/isair/repos. I'm going to check and see what the server I'm using does different. |
I think these are issues with react-native. |
I'm still getting this error on firefox with latest version of react and superagent. After long debugging my work around is to add request.set('Accept', 'application/json') or whatever type you expect. This way the browser will treat the response as json even the response content type is something different. |
I'm still getting this on react native android. It works fine for iOS, but the res.body is null and res.type is an empty string. |
Same issue here |
Did anyone get this working? I've tried doing |
@icefoggy Can you share insight if you got it fixed? |
Has anyone figured this out yet? |
I'm having the same issue now. res.body is null. |
Use my package in NPM called Frisbee
|
This issue has been closed, because it's not a bug in superagent. Have you tried reporting this bug to react-native authors? |
I'm not using React Native |
@mienaikoe Sorry, this bug is about react-native only. But in your comment you say "the response is text/json, and I'm using a plain get request." — try |
@jsergiu Your solution worked for me, used it in react static starter app. Thanks. |
same here, if my API return content-type header |
i have a problem probably like this。 |
Using react-native 0.4.1, both my request.get and request.post methods are working, but the res.body is undefined, forcing me to manually JSON.parse the res.text:
When calling this from regular React, it's working perfectly.
The text was updated successfully, but these errors were encountered: