2017-06-03 39 views
0

反応しnodejsは/私は私のセッションを作成していると私は郵便配達でテストするとき、それは私のために動作しますが、私はaxiosとそれをロードするときはreactjs/axiosとのセッションをロードしないでください

を表現し、私は自分のアプリケーションを持っていますそれはいつも私は、配列を空に返し、それは私のセッションを表示しません反応し、これは私のコード

エクスプレス

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 
       } 
      }) 
    }) 

と反応すると/ axios

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

答えて

0

ExpressセッションはセッションIDをクッキーに保存しますが、AxiosレスポンスにはCookieデータが含まれないため、設定されたセッションIDは表示されません。クッキーにアクセスするには、document.cookieオブジェクトを使用できます。

例:

axios.post("http://localhost:8080/sign_up_profile", data) 
    .then((response) => { 
     console.log("Cookies are ", document.cookie) 
    }) 
    .catch((err) => { 
     console.log("Something went wrong!", err) 
    }); 
関連する問題