Hi people i new in react native whit expo and i have a problem...
I have this function in another file :
const login = async(email, password) => {
axios.post('/login', {
email : email,
password: password
}).then(response => {
let info = response.data.data.token
AsyncStorage.setItem('scute-user-token', info)
}).catch(error => {
Alert.alert(error)
})
const Scutetoken = await AsyncStorage.getItem('scute-user-token')
if (Scutetoken !== null ){
return true
} else {
return false
}
}
and I call in :
login = async() => {
const login = await funciones.login(this.state.email, this.state.password)
console.log(login)
if(login == true){
const me = funciones.yo()
if(me == true){
this.props.navigation.navigate('Home')
} else{
await AsyncStorage.clear()
Alert.alert('No se puede acceder en este momento')
}
}
}
¿The problem? the problem its why the function always return false even if save the token i try solved of different ways but i not found solution....
Thx 4 the answers