Skip to content

Instantly share code, notes, and snippets.

@toshiyukihina
Last active December 18, 2015 10:44
Show Gist options
  • Save toshiyukihina/d6cb5280d23df24f56a3 to your computer and use it in GitHub Desktop.
Save toshiyukihina/d6cb5280d23df24f56a3 to your computer and use it in GitHub Desktop.
let request = require('superagent');
let agent = request.agent();
let account = {username: 'xxxx@company.com', password: 'xxxxx'};
const URI = 'http://xxx:3000/api/v1';
request.post(`${URI}/user_session`).send(account).type('json')
.end((err, res) => {
agent.saveCookies(res);
let req = request.get(`${URI}/devices`);
agent.attachCookies(req);
req.end((err, res) => {
console.log(res.text);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment