1

N.B. 처음으로 게시하는 경우 서식 오류, 질문 양식 등을 수정하는 것을 망설이지 말라.React-Native : TypeError : undefined가 (가) 객체가 아닙니다.

나는 네이티브 반응을 보이기는 비교적 쉽지만 API를 사용하여 Google 시트를 변경하는 앱을 만들려고 애 쓰고있다. . 나는의 OAuth 인증 (repo-linked-here)을 처리하기 위해 패키지를 발견하지만, 다음과 같은 오류 던지는 것 같다 :

... 
import OAuthManager from 'react-native-oauth'; 

const manager = new OAuthManager('App'); 

export default class App extends Component { 
    constructor(props){ 
    super(props); 
    this.state = { 
     isSignedIn: false 
    }; 
    } 
    componentDidMount(){ 
    manager.configure({ 
     google: { 
     callback_url: 'http://localhost/google', 
     client_id: '*************', 
     client_secret: '************' 
     } 
    }) 
    .then(resp => console.warn(resp)) 
    .catch(err => console.warn(err)); 
    } 
... 

반작용 네이티브 :

여기
TypeError: undefined is not an object (evaluating 'Module[fn]') 

입니다 내 index.android.js 대부분의 -oauth는 콜백에 'http://localhost/google'을 사용하고 build.gradle 파일에 몇 줄을 추가하면 콜백/링크가 제대로 작동 함을 나타냅니다.

모든 조언을 부탁드립니다.

답변

1

귀하의 전화 번호는 authorize입니다. manager입니다. 또한 당신은 추가 할 수 없습니다 then & catchconfigure에 :

componentDidMount(){ 
    manager.configure({ 
    google: { 
     callback_url: 'http://localhost/google', 
     client_id: '*************', 
     client_secret: '************' 
    } 
    }); 
    manager.authorize('google', {scopes: 'profile email'}) 
    .then(resp => console.warn(resp)) 
    .catch(err => console.warn(err)); 
}