I have an async function for getting token from firebase. But when I fired this function returned undefined. When I consol.log my async function it's return token. After Yield call, returns undefined. I am a new student and I have no idea what is happening. So..If anyone can help me with this problem It's really helped me with my studies. Thank you.❤️
React.useEffect(() => {
dispatch(AddUserTokenListener())
}, [])
async function getUserIDAsync() {
const idTokenResult = await firebase.auth().currentUser.getIdTokenResult();
// console.log('User JWT: ', idTokenResult); But this will return token
}
export function* getUserToken() {
try {
const userToken = yield call(getUserIDAsync);
// console.log(userToken) this will return undefined .
if (userToken) {
console.log(userToken)
yield put(AddUserTokenSuccess(userToken))
}
} catch (error) {
console.log(error)
yield put(AddUserTokenField(error))
}
}