Hi,
I'm relatively new to Sails and I use it as a back-end API for an Angular app. I like a lot the 'out of the box' blueprint actions because they work great with Angular "$resource". But it turns out I need to do some extra work (call a web service with "http.request") before or after running the blueprint methods. I already tried to find a solution, but none seems to work for me.
I don't want to use lifecycle callbacks on the model because my purpose is not to modify the attributes of the object. Also, declaring "var http = require('http');" in the model seems like a no-go for me.
module.exports = {
delete: function (req, res, next) {
// Call some web service before deleting the object
next();
},
.....
The solution I found is not nice and thus I want to do it better. For now, I've create another method in the controller, say "callWebService", which I call on the client side once the blueprint call is done. That's ugly, right? So I'm using Sails 0.9.4, but I'm wondering whether in version 0.10 it's perhaps easier to do this.
Thank you all for your help!