superagent: react-native: res.body is null, only res.text is working
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:
request
.post('http://10.0.0.3:9091/auth')
.type('json')
.send({
email: 'xxx',
password: 'xxx',
})
.end((error, res) => {
if (res.status === 200) {
console.log(res.body); // undefined
var token = JSON.parse(res.text).token; // working
...
When calling this from regular React, it’s working perfectly.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (3 by maintainers)
same here, if my API return content-type header
application/vnd.profiles+json
instead ofapplication/json
res.body is null and res.text has content.