I am using apollo client to perform an auto login with refresh token. The code I use is:
const expirationTime = exp * 1000 - 60000;
if (Date.now() >= expirationTime) {
await client //this is how user relogin
.mutate({
mutation: USER_LOGIN,
variables: { rt: localStorage.getItem("refreshToken") },
})
.then((response) => console.log(response.data))
.catch((err) => console.error(err));
}
But I am not sure whether this is the right way, because my app seems to crash when I do this. I read the documentation for react but couldn't find anything other than useMutation