Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub Content Analysis BLOCK w/ Diffbot
export default request => {
let xhr = require('xhr');
let query = require('codec/query_string');
let clientToken = 'YOUR_CLIENT_TOKEN';
let apiUrl = 'https://api.diffbot.com/v3/analyze';
let queryParams = {
token: clientToken,
url: request.message.url
};
let url = apiUrl + '?' + query.stringify(queryParams);
return xhr.fetch(url)
.then((response) => {
let json = JSON.parse(response.body);
request.message.diffbotResponse = json;
return request.ok();
})
.catch((err) => {
console.log('error happened for XHR.fetch', err);
return request.ok();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment