Lab 8

Today we are going to talk about remote APIs

But first, download this repo:

https://github.com/shovon/iat381-lab8.git

TJ's SuperAgent: "AJAX with Less Suck"

We are going to be using SuperAgent, instead of jQuery AJAX

The benefit of using SuperAgent is that it sucks a lot less than just XHR, and waaaaay less than jQuery AJAX (who the hell made that stuff?)

SuperAgent is much more inline how most HTTP libraries are going to use.


request
  .get('https://api.imgur.com/3/gallery/hot/viral/0.json')
  .set('Authorization', 'Client-ID 'API KEY HERE'')
  .end(function (error, res) {
    var parsed = JSON.parse(res.text).data.filter(function (image) {
      return image.type === 'image/jpeg';
    }).map(createImageObject);
  }.bind(this));