jwt decode link: https://www.npmjs.com/package/jwt-decode

jwt decode link: https://www.npmjs.com/package/jwt-decode


npm i jwt-decode

  1. verifyJwt.ts****
    import { jwtDecode } from ‘jwt-decode’;
    export const verifyToken = (token: string) => {
    return jwtDecode(token);
    };

  2. 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)



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.