Using sails.io pubsub works with shortcuts, but not with RESTful record creation

I'm having an issue where I'm getting events from the sails resourceful pubsub when I create a record with the shortcut routes, but not with the RESTful routes.

In my client code, I have a sails socket that I listen to for the model:

io.socket.on('users', function(event){console.log(event);})

If I use a shortcut route to create a record (http://localhost:1337/users/create?name=test), I get the callback in the console as expected:

>{verb: "created", data: {…}, id: 44}

However, if I use the socket to post from the client, the callback never fires.

io.socket.post('/users', { name: 'test' });

The record is created in the DB, and even more confusing is that the Sails server log says its publishing the message:

silly: Published message to  sails_model_create_users :  { verb: 'created',
  data:
   { name: 'test',
     createdAt: '2017-10-09T02:58:18.218Z',
     updatedAt: '2017-10-09T02:58:18.218Z',
     id: 44 },
  id: 44 }

I'm the using generic blueprints, sails is v0.12.14. Any ideas what I'm doing wrong?

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image