Answer the question
In order to leave comments, you need to log in
How to correctly get user data by jwt token in Nuxt?
Hello! I created this route:
// /api/auth/getUserByToken
router.post(
'/getUserByToken',
passport.authenticate('jwt'),
(req, res) => {
res.json({
username: req.user.username,
email: req.user.email,
id: req.user.id
});
}
);
nuxtServerInit({ dispatch }) {
dispatch('auth/autoSignin');
dispatch('auth/getUserByToken');
}
setUser(state, user) {
console.log(user); // Нужная информация пришла
state.user = user;
console.log(state.user); // Стейт обновился, но на клиенте не появился
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question