The error is :
Uncaught Error: Module name "aylien_textapi" has not been loaded yet for context: _. Use require([])
and my code is:
window.addEventListener('button', summarizeNow());
function summarizeNow() {
var AYLIENTextAPI = require('aylien_textapi');
var textapi = new AYLIENTextAPI({
application_id: "12049eaa",
application_key: "0050eee15d54ac3dbd69d868fc1e8570"
});
var current = window.location.href
var sum = document.getElementById("summary");
textapi.summarize({
url: 'current',
sentences_number: 5
}, function(error, response) {
if (error === null) {
response.sentences.forEach(function(s) {
sum.innerHTML = sum.innerHTML + s;
});
}
});
}
I've googled it and the documentation says that require('aylien_textapi') is a top-level require call that should use require([]), although I'm not too sure how to implement this.
Any help is appreciated, thanks!