I am using AWS amplify in my app, I implemented a login function with google. But after login, i get this error Unhandled Rejection (TypeError): user.getSession is not a function .
I have used Auth.federatedSignIn function for the login.
Here is my code:
const responseGoogle = async (response) => {
try {
setLoading(true);
const user = {
name: response.profileObj.name,
email: response.profileObj.email
};
const password = await Auth.forgotPassword(user.email);
let expires_at = addMilliseconds(new Date(), 3600 * 1000).getTime();
const result = await Auth.federatedSignIn(
'google',
{ token: response.tokenId, expires_at },
user
);
console.log(result);
console.log('heree');
history.push('/classes/google');
setLoading(false);
setUserInfo(loadedUsers, email);
} catch (error) {
console.log(error);
if (error.message !== `Cannot read property 'name' of undefined`) {
enqueueSnackbar(error.message, { variant: 'error' });
}
setLoading(false);
}
};
The response is the response that I get from google.
does anyone know why I am getting this error? appreciated any type of help. Thanks