modelagent

0.0.1 • Public • Published

modelagent

SuperAgent with promise and url pattern support.

Promises

Returns an ES6 promise if no callback is specified.

request.get('/api/pets').end().then(function(res) {
  // do something with res
}).catch(function(err) {
  // caught an error
});

URL pattern

Creates a reusable url pattern based agent. Unspecified keys will be removed from the url.

var pets = request.api('/pets/:id');
 
// GET /pets
pets.get().end()
 
// GET /pets/1
pets.get({id: 1}).end()
 
// POST /pets
pets.post({name: 'Old Yeller'}).end();
 
// PATCH /pets/1
// id is not included in body
pets.patch({id: 1, name: 'New Yeller'}).end();

Readme

Keywords

Package Sidebar

Install

npm i modelagent

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • litek