Skip to content

Instantly share code, notes, and snippets.



Last active Jan 1, 2016
What would you like to do?
DiffBot article API for Node
var querystring = require('querystring'),
util = require('util'),
request = require('request');
var ARTICLE_URL = '';
exports.article = function(url, token, cb, options) {
options = options || {};
if (!url || !token || !cb) throw TypeError('3 arguments required.');
options.url = url;
options.token = token;
var query = querystring.stringify(options);
request(ARTICLE_URL + query, function(err, res, body) {
if (err) return cb(err);
// handle syntax errors in the JSON
var data;
try {
data = JSON.parse(body);
} catch (e) {
cb(null, data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.