node.js - Changing data before Create in Sails API call -


in taskcontroller i'm trying insert current user (i.e. user created task) newly created task.

mostly i've been trying different ways override create() in override call original blueprint , let continue usual.

i found bunch of answers seem outdated or otherwise not working. wonder if there's more updated.

i'm using sails v1.0.0-37

solution:

in \tasks\api\controllers\taskcontroller.js

  create: function (req, res) {     req.query.createdby = req.user.id;     task.create(req.query)       .exec(function (err) {         if (err) {           return res.servererror(err);         }         return res.ok();       });   } 

my issue:

during testing , experimenting created empty lifecycle callback of beforecreate. since empty, never called cb() request got stuck.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -