阿波罗客户的突变
我正在使用Apollo客户端执行具有刷新令牌的自动登录。我使用的代码是:
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));
}
但是我不确定这是否是正确的方法,因为当我这样做时,我的应用似乎会崩溃。我阅读了React的文档,但除了Usemuont之外找不到其他任何内容
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论