• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Use normal post and get functions

Scheduled Pinned Locked Moved NodeBB Development
3 Posts 2 Posters 287 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • NoduleJSN Offline
    NoduleJSN Offline
    NoduleJS
    wrote on last edited by NoduleJS
    #1

    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

    1 Reply Last reply
    0
  • oplik0O Offline
    oplik0O Offline
    oplik0 Plugin & Theme Dev Community Rep
    wrote on last edited by oplik0
    #2

    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)

    1 Reply Last reply
    0
  • NoduleJSN Offline
    NoduleJSN Offline
    NoduleJS
    wrote on last edited by NoduleJS
    #3

    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).

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development