I want to perform an action if and only if the user details have been fetched but they are fetched after the token and the logical operator && is running even if the condition is false and user details are not there
try {
await axios.post(`${BASE_URL}/api/moralis/login`,
{
userObjectId: id,
sessionToken: sessionToken
})
.then((resp) =>
AsyncStorage.setItem('token', resp.data.user.token),
AuthStore.setToken()))
{
Object.keys(UserStore.state.user).length &&
(
console.log('run===>', Boolean(Object.keys(UserStore.state.user).length)),
navigation(),
setLoading(false))
}
} catch (error) {
Errored(error)
setLoading(false)
}
I don't know what other parameter do you want to check but i feel you want something like this?
or with callback function