2017-12-01 14 views
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(); 
        (...) 
    
  • 답변

    0
    1. 를 기다리는 것 같다 렌더링 코드를 읽어보십시오. 반응 코드 및 반응 코드의 일반적인 구성