Reputation: 538
nested callback function I tried with arrow function, bind function as well but function is not triggering after getting facebook access token I need to call api with this.handleApiCalls here my code snippet
const FBSDK = require('react-native-fbsdk')
const {
LoginButton,
AccessToken
} = FBSDK
class LoginScreen extends React.Component {
constructor () {
super(props)
}
handleApiCalls = () => {
alert("handle the api calls");
}
render () {
return <View style={{justifyContent: 'center',
alignItems: 'center'}}>
<LoginButton
publishPermissions={['publish_actions']}
onLoginFinished={
// first call back
(error, result) => {
if (error) {
console.log('error:', error);
} else if (result.isCancelled) {
alert('login is cancelled.')
console.log('login is cancelled:', result);
} else {
// second callback
AccessToken.getCurrentAccessToken().then((data) => {
console.log('Access_Token:'+data.accessToken.toString())
// ================ how to call this function ===============
this.handleApiCalls
})
}
}
}
onLogoutFinished={() => alert('logout.')}/>
</View>
}
}
Upvotes: 0
Views: 308
Reputation: 8936
if console.log('Access_Token:'+data.accessToken.toString())
is working then just change this.handleApiCalls
to this.handleApiCalls()
to invoke it.
Upvotes: 2