My express server auths with github, post to my rails api then returns the data in an axios promise. I need to set a cookies from the data. Is it possible?
app.get('/auth/github/callback',
passport.authenticate('github', { failureRedirect: '/login' }),
function(req, res) {
const profile = res['req']['user']
const json = Object.assign({}, profile['_json'], { regKey: "123456" }, { email: profile['emails'][0]['value'] })
axios.post(`http://localhost:3001/users/`, json )
.then(user => res.cookie("auth_token", user.data.auth_token, { maxAge: 12000, httpOnly: false } ))
res.redirect('/');
})
Im getting this error:
UnhandledPromiseRejectionWarning
I've read the answer and was wondering how to set a browser cookie from the returned data? For this, httpOnly will be set to false. For what Im doing, it's ok. I need to set user.data.auth_token as a cookie. Possible with other libraries?
via Sylar
No comments:
Post a Comment