I have code to set the session that works in postman
First: set my session and it work
const user = {
name: 'afshin',
};
req.session.user = user
res.status(200).send({data:req.session.user,status:200});
Second: retrieve session
console.log(req.session.user)
This works when I make a request with postman. But when I use on client (nuxt axios) it isn't working
Third: on the front-end
this.$axios
.post(
'http://localhost:7000/auth/session-result',
{ data: 'salam' },
{
headers: { 'Content-Type': 'application/json' },
},
{ withCredentials: true },
)
.then((res) => {
console.log(res)
})
.catch((error) => {
console.log(error)
this.setState({
errorMessage: `Server Error`,
loading: false,
})
})
What am I doing wrong the front-end?
CodePudding user response:
req
is for server side, so you will not get it on the client side, as shown on this page, this is only for server side.