Friday 2 June 2017

Do not load the session with reactjs/axios

I have my application with react and nodejs / express

I am creating my session and it works for me when I test in postman, but when I load it with axios in react it does not show me the session, it always returns me empty the array, this is my code

Express

app.use(session({ secret: '23eirofjiw8'resave: false, saveUninitialized: false }));

app.get('/token', function(req, res, next){
       userServices.verificaToken(req.query, function(err, token){
                if(!token){
                    return res.json({ status: 'FAIL', message: 'Usuario Innactivo'}) 

                } else{
                    userServices.activaUsuario(req.query.email, function(err, Activado){
                        if (Activado) {
                            return res.json({ status: 'SUCCESS', message: 'User activate', user: req.query.email });                
                        }
                    })
                   req.session.user=req.query.email 
                }
            }) 
    })

and with react / axios

axios.post("http://localhost:8080/sign_up_profile", data)
    .then((response) =>{
        console.log(response)
    })
    .catch((err)=>{
      console.log(err)
    })



via FERNANDO ORTIZ

No comments:

Post a Comment