New york times bestsellers api implementation
This commit is contained in:
1
app.js
1
app.js
@ -69,7 +69,6 @@ app.get('/api/scraping', api.getScraping);
|
||||
app.get('/api/github', passportConf.isAuthorized, api.getGithub);
|
||||
app.get('/api/lastfm', api.getLastfm);
|
||||
app.get('/api/nyt', api.getNewYorkTimes);
|
||||
app.get('/api/twilio', api.getTwilio);
|
||||
app.get('/api/etsy', api.getEtsy);
|
||||
app.get('/api/twitter', passportConf.isAuthenticated, api.getTwitter);
|
||||
app.get('/api/aviary', api.getAviary);
|
||||
|
@ -1,5 +1,6 @@
|
||||
var config = require('../config/config');
|
||||
var User = require('../models/User');
|
||||
var querystring = require('querystring');
|
||||
var async = require('async');
|
||||
var cheerio = require('cheerio');
|
||||
var request = require('request');
|
||||
@ -144,13 +145,6 @@ exports.getGithub = function(req, res) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/twilio
|
||||
*/
|
||||
exports.getTwilio = function(req, res) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/aviary
|
||||
*/
|
||||
@ -173,10 +167,14 @@ exports.getEtsy = function(req, res) {
|
||||
* New York Times API example
|
||||
*/
|
||||
exports.getNewYorkTimes = function(req, res) {
|
||||
|
||||
res.render('api/nyt', {
|
||||
title: 'New York Times API',
|
||||
|
||||
var query = querystring.stringify({ 'api-key': config.nyt.key, 'list-name': 'young-adult' });
|
||||
var url = 'http://api.nytimes.com/svc/books/v2/lists?' + query;
|
||||
request.get(url, function(error, request, body) {
|
||||
var bestSellers = JSON.parse(body);
|
||||
res.render('api/nyt', {
|
||||
title: 'New York Times API',
|
||||
books: bestSellers.results
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,5 @@ block content
|
||||
a(href='/api/tumblr') Tumblr
|
||||
li
|
||||
a(href='/api/twitter') Twitter
|
||||
li
|
||||
a(href='/api/twilio') Twilio
|
||||
li
|
||||
a(href='/api/scraping') Web Scraping
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends ..layout
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
.page-header
|
||||
|
Reference in New Issue
Block a user