I am doing a network request very similar to the example code of react-native.
Networking.js
export default class Networking {
static tryLogin() {
return fetch('https://exampleserver.com')
.then((response) => response.json())
.then((responseJson) => {
return responseJson;
})
.catch((error) => {
console.error(error);
});
}
}
I'd like to retrieve responseJson and process it in another class, however, .then((responseJson)
is returning objectObject instead of my JSON. I am calling this method using Networking.tryLogin();
When replacing return responseJson
with alert(responseJson)
it works as expected, so it has to be something with the returning.
Edit: When doing console.log() I am getting:
Promise {
"_40": 0,
"_55": null,
"_65": 0,
"_72": null,
}