0
Google 계정을 사용하여 로그인 한 사용자로부터 데이터를 가져오고 싶습니다. 로그인 할 수 있고 토큰을 받지만 데이터를 가져올 수 없습니다. 단순히 응답하지 않는 것 같습니다. 던져진 오류, 그냥 엑스포 데이터에서 Google API의 데이터를 가져 오는 중
this.logIn();
에 대한 호출에 대한 await
당신이 자바 스크립트에서 비동기 기능과 약속을 읽어 추천 누락 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(result.accessToken);
getUserInfo(result.accessToken);
return result.accessToken;
} else {
return {cancelled: true};
}
} catch(e) {
return {error: true};
}
}
getUserInfo(accessToken) {
fetch('https://www.googleapis.com/userinfo/v2/me', {
headers: { Authorization: `Bearer ${accessToken}`},
}).then(res => {console.log(res)});
}
render() {
this.logIn();
(...)