Last active
December 30, 2016 16:24
-
-
Save sunnygleason/8aa0d703a1a0baf8779b66dc1ebeaec2 to your computer and use it in GitHub Desktop.
PubNub Content Analysis BLOCK w/ Diffbot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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