ubaltaci
ubaltaci

Reputation: 1016

Saving user in sails.js

In sails.js 0.9.7, how can I debug model.create() if done() function never called ?

I have a form like that;

<form action="/user/create" method="post">

And in my UserController;

create: function (req, res, next) {

    User.create(req.params.all()).done(function (err, user) {
        if ( err ) {
            return next(err);
        }
        else {
            res.json(user);
        }
    });
},

Also; I check req.params and as it supposed to be but done() function never called and POST request hanging in client side.

Upvotes: 2

Views: 4220

Answers (1)

JohnGalt
JohnGalt

Reputation: 2881

In your User model, you need to use the next() method. This method passes control back to the next piece of middleware on the stack. Without it, it blocks execution.

// Lifecycle Callbacks
beforeCreate: function(values, next) {
  next();
},

Upvotes: 1

Related Questions