I am sending data from my database to my React-native application but when I receive the response from my GET request, I cannot get my data out from the response.
I have tried with JSON.stringify
, JSON.parse
, putting in response[0], response.name (one of my objects in my response), etc.
alert(JSON.stringify(response));
This is how my current response looks like.
My response body have 4 objects, _key, name, email and school. I want to be able to see and save all these objects from my response.
If you are using fetch and calling:
fetch('http://yourdomain.com', {method: 'GET',})
.then(response => {alert(JSON.stringify(response));)
Then you need to call a second .then()
to get the body of the response:
fetch('http://yourdomain.com', {method: 'GET',})
.then(response => {response.json()})
.then(data => {alert(data)})
.catch(error => console.log(error))