There are several problem in your code:
- the post request in
form
instead ofjson
, so you need the method.type('form')
- the returned cookie at:
res.body.json.data.cookie
- headers in superagent must be in lower case:
res.headers['set-cookie']
Full code:
superagent
.post( 'https://pay.reddit.com/api/login/' )
.type('form') // send request in form format
.send( { api_type: 'json', rem: 'True',
user: USER, passwd: PASS } )
.end( function(err, res) {
console.log( 'Session cookie: ', res.body.json.data.cookie || res.headers['set-cookie']);
});