首页 > 其他分享 >token失效解决办法

token失效解决办法

时间:2022-12-03 19:46:59浏览次数:47  
标签:解决办法 return secure window token export 失效 const

import jwt from "jsonwebtoken";
export const secure = 'abcd123xxxxxxxxxxxx'

// 解密获取用户信息
export const checkLogin = () => {
   const token = getToken();
   if (!token) return null;
   return jwt.decode(token, secure);
}
export const getToken = () => {
   return window.sessionStorage.getItem('token');
}
return window.sessionStorage.getItem('token');

结论:好用!

标签:解决办法,return,secure,window,token,export,失效,const
From: https://www.cnblogs.com/jycom/p/16948630.html

相关文章