0

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!

Jeffrey Feng
  • 1
  • 1
  • 2
  • 1
    You should really [consult the documentation](http://requirejs.org/docs/api.html#data-main) for RequireJS. You're attempting to use it like you have CommonJS modules but that's not really how RequireJS is used. – Mike Cluck Mar 21 '16 at 23:14
  • I used their data-main entry point and tried using require.config but I could not get it to work. – Jeffrey Feng Mar 22 '16 at 00:56

0 Answers0