I am currently using React Native with Expo for an application. I made a login using a Google account and I try to take some information about the user using Google’s API. I use “fetch” for this, but it doesn’t work at all, not even printing an error. I wrote a wrong link for “fetch” and still not even an error thrown. I am running the code on my devices remotely using Expo. Here is the code:
async logIn() {
try {
const result = await Expo.Google.logInAsync({
androidClientId: '645999128246-gv9drk3gtad84ikeifg37p4k5phdu705.apps.googleusercontent.com',
// iosClientId: '116235701426-lsptd400ahlctrlveoe4vlg96hcjne51.apps.googleusercontent.com',
scopes: ['profile', 'email'],
});
if (result.type === 'success') {
//console.log("AICI");
getUserInfo(result.accessToken);
return result.accessToken;
} else {
return {cancelled: true};
}
} catch(e) {
return {error: true};
}
}
getUserInfo(accessToken) {
fetch('Wronglink', {
headers: { Authorization: `Bearer ${accessToken}`},
}).then(res => {console.log(res);}).catch (e => {console.log(e);});
return;
}
render() {
this.logIn(); (.......)