Dynamic content

NodeBB Plugins
  • Hey guys, first of all great application!

    Second, I'm trying to add a link to the header of my forum via a plugin. This links text will be chosen by what is gets from an external api. To get the information from the external API, I run a request like this:

    var request = require('request');
    request('http://www.google.com', function (error, response, body) {
    if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.
    }
    })

    This code is run async afaik, causing the body to be returned undefined until the request is completed.

    My question is, how can I get the async body information and use it for the header text.

  • Interesting.

    Have you seen this?

    https://github.com/psychobunny/nodebb-plugin-static-page

    Maybe instead of a straight up text link I would do something like <div id="my-link"></div>

    And then embed a client-side script (see this for an example on how to do that), which makes an api call to your request script, checks the callback and then replaces the text of #my-link. Hope you follow.

  • @psychobunny nodebb-plugin-mousetrap is not in the NPM registery and I also noticed that nodebb-plugin-designer has mousetrap as keyword and description.


Suggested Topics


  • 0 Votes
    2 Posts
    372 Views
  • 0 Votes
    6 Posts
    3797 Views
  • 0 Votes
    1 Posts
    933 Views
  • 0 Votes
    4 Posts
    2196 Views
  • 0 Votes
    5 Posts
    2187 Views