1

N.B.第一次發佈,所以請不要猶豫,以糾正格式錯誤,問題形式等。React-Native:TypeError:undefined不是對象

我是相對較新的react-native,但試圖建立一個應用程序,使用他們的API 。我發現了一個包來處理OAuth認證(repo-linked-here),但它似乎是拋出以下錯誤:

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

這裏是我的大多數index.android.js的:

... 
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)); 
    } 
... 

陣營本土-oauth似乎表明,如果我使用'http://localhost/google'作爲回調,並在build.gradle文件中添加幾行,那麼回調/鏈接應該可以正常工作。

任何和所有的意見,將不勝感激!

回答

1

我認爲你不是從manager調用authorize。你也可以不加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)); 
}