0.0.1 • Published 10 years ago

modelagent v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

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();