npm i jwt-decode
verifyJwt.ts****
import { jwtDecode } from 'jwt-decode';
export const verifyToken = (token: string) => {
return jwtDecode(token);
};Login.tsx****
const onSubmit = async (data) => {
console.log(data);
const userInfo = {
id: data.id,
password: data.password,
};
const res = await login(userInfo).unwrap();
const user = verifyToken(res.data.accessToken);
dispatch(setUser({ user: user, token: res.data.accessToken }));
};
Top comments (0)