Use normal post and get functions

NodeBB Development
  • Hello. There are certain cases where I can't find the right hooks to do what I want. So, sometimes i use custom POST and GET express functions (in my plugin script), without any hook, and invoke them directly from the client with jquery.
    Is it a bad practice? Im a newbie to nodebb so I don't know. Is user authentication also valid in custom functions?

    New Project (20).jpg

  • Have you tried using websockets?

    NodeBB core and many plugins utilize websockets for communication between front-end and back-end and I think they will be easier for bi-directional communication than utilizing raw post/get.

    Look here for instructions (I think you can use async/await instead of callbacks if you want. I'm certain you will be able to in 1.13.0, as NodeBB is currently in the process of being refactored to use async functions, but it might work even now 🙂 ).

    Example usage in a plugin (client-side script)

  • I think i will use websockets, thanks for the advice. At moment i'm using callbacks only because can't do different.
    Probably async/await will be available from the next version (I've read that too).


Suggested Topics