It seems like you are using JWT. To decode this type of token you can simply use jwt-decode library. For example, in ReactJS:
import { jwtDecode } from 'jwt-decode' // import dependency
// If using v3 or earlier, use this instead:
// import jwtDecode from 'jwt-decode' // import dependency
// some logic
axios.post(`${axios.defaults.baseURL}/auth`, { email, password })
.then(res => {
const token = res.data.token;
const user = jwtDecode(token); // decode your token here
localStorage.setItem('token', token);
dispatch(actions.authSuccess(token, user));
})
.catch(err => {
dispatch(actions.loginUserFail());
});