Native sample response returns an odd response

I use fetch to get some stuff from the API:

fetch('http://facebook.imtqy.com/react-native/movies.json') .then( data => console.log(data), error => console.log(error) ) 

But I'll be back, this is the next object, not the actual data

 _bodyBlob: Blob _bodyInit: Blob headers: Headers ok: true status: 200 statusText: undefined type: "default" url: "http://facebook.imtqy.com/react-native/movies.json" 

Can someone explain to me what happened? Am I doing something wrong?

+5
source share
1 answer

To get the data from the response, you must call data.json(); Example:

 fetch('http://facebook.imtqy.com/react-native/movies.json') .then((response) => response.json()) .then((data) => { console.log(data); }) .catch((error) => { console.log(error); }); 

(Assuming the answer is in json).

+7
source

All Articles