cannot load webtorrent in my plugin.

  • i want write a plugin about watch webtorrent video in nodebb.but when i use these in my chrome browser,it does not work.

    var wtclient = new WebTorrent();

    output show me that

    Uncaught ReferenceError: WebTorrent is not defined
        at <anonymous>:1:16

    the whole code is in my github.
    how can i fix this problem?

    software version

    nodebb: 1.6.1
    chrome: 62.0.3202.62
    windows 10
    node 6.8.0

  • Global Moderator

    Classic JS error. You need to provide a callback to getScript and do everything that depends on WebTorrent in there. Better yet, just use require:

    require([''], function (WebTorrent) {
      var wtclient = new WebTorrent();
      // etc

  • @pitaj thank you,it works well.


Suggested Topics


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.