Thursday 8 June 2017

Can i use returning promise in socket.io "socket.on(eventName, callback)"?

Can i use returning promise in socket.io "socket.on"? Like the following code.

    socket.on('news', function (data) {
      return News.findOne({id: data.id})
        .then((news) => {
          socket.emit('event', data.body);
          return news;
        })
    });



via ashnamuh

No comments:

Post a Comment