Read 07: APIs continued - corey-marchand/data-structures-and-algorithms GitHub Wiki

What is SuperAgent?

  • lightweight progressive ajax API crafted for flexability, readability, and low learning curve.

Request Basics

  • requests can be made by invoking the appropriate method on the request object, then calling .then() or .end()
  • For example: request .get('/search') .then(res => { // res.body, res.headers, res.status }) .catch(err => { // err.message, err.response });

--GET requests--

.query() method accepts objects, which when used with the GET method will form a query-string, the following will produce a path

  • request .get('/search') .query({ query: 'Manny' }) .query({ range: '1..5' }) .query({ order: 'desc' }) .then(res => {

    });