Custom plugin: Which is better jQuery post Or socket.emit and Why?

  • I want to clarify which approach shall I use to send the data from the client to the server. The jQuery post method or socket.emit?

    My client side js

    var userData = { location: markerLocation };
    socket.emit('', userData, function (err, data) {
    if (err) {
        return app.alertError(err.message);

    My plugin controller.js

    Pl. help me write this piece of code: Shall I use socket.on or some other socketAPI? Also pl. guide me the right approach to overwrite the existing data (if any) for this particular req.uid in Mongo DB

    Thanks in anticipation

  • Global Moderator

    You can do it either way. If you know how to handle posts then I'd suggest doing that. Otherwise, there are examples of socket usage in various plugins.

  • Pita Could you pl. pinpoint to the exact plugin which handles the backend that I am looking for i.e. socket.on plus MongoDB overwrite

    I tried to have a look at several of them but they are a little confusing

    Thank you

  • I am done with this. If somebody needs help for this topic, he/she may send a notification to me.



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