Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub HTML Sanitizer BLOCK JavaScript
export default (request) => {
const xhr = require('xhr');
const query = require('codec/query_string');
const userId = 'YOUR_USER';
const apiKey = 'YOUR_API_KEY';
const outputType = 'plain-text';
let apiUrl = 'https://neutrinoapi.com/html-clean';
let params = {
'user-id': userId,
'api-key': apiKey,
'content': request.message.payload,
'output-type': outputType
};
apiUrl = apiUrl + '?' + query.stringify(params);
return xhr.fetch(apiUrl).then((response) => {
request.message.clean_html = response.body;
request.message.original_html = request.message.payload;
delete request.message.payload;
return request.ok();
}).catch(err => {
console.error(err);
});
};
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.