Clearly SuperAgent supports custom HTTP headers:
request
.post('/api/pet')
.send({ name: 'Manny', species: 'cat' })
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.end(function(err, res){
if (res.ok) {
alert('yay got ' + JSON.stringify(res.body));
} else {
alert('Oh no! error ' + res.text);
}
});
My Question:
- If I'm pulling down SuperAgent via npm, how can I inject my own HTTP header across all requests that SuperAgent makes?
- Note: I'm entire willing to create a new npm package that extends SuperAgent if necessary.