this is my function A :
export function registerUser(mobile) {
...
}
this is function B :
async function onLogin () {
await registerUser(global.registerMobile)
>>>>>>>>alert(123)
}
now I want to run alert(123) after registerUser function execute Please Help Me...
Here is my example code
export const registerUser = (mobile) => new Promise(resolve => { Axios.get('SOME URL').then(res => { resolve(res.data); }); });
mark your registerUser function async
export async function registerUser(mobile) {
await // do async stuff
}
or in case you are using promise, you should return it to be able to await for it in onLogin
export function registerUser(mobile) {
return fetch('..register url..', options)
}
also read docs for react-native alert https://facebook.github.io/react-native/docs/alert
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.