I have been playing with node.js and more recently sails.js. In node.js I was using express and so it was easy to define multiple paramters by using Routers.get however I am struggling in sails.
I have created a api using the built in command and noticed that this will take one param that defaults to a name of id, this is fine if I just wish to use the one param but I am trying to call a function that fires a stored procedure that requires 4 params. These are being called via an Android device.
Using node I was sending something like
myserveraddress/sendgrn/" + 1 + "/" + User + "/" + 1111 + "/" + 22)
This doesn;t work in sails, can anyone point me in the right direction?
In your config/route.js you could also have manually defined a route like this :
'POST /sendgrn/:param1/:param2/:param3/:param4' : "SomeController.sendgrn"
And then to get your params in your controller method for instance :
sendgrn: function(req, res){
var p1 = req.param("param1");
var p2 = req.param("param2");
...
// do something with the params
}
More about routes syntax in sails : here
In the end I used the default create method and added my params like:
/myserver/myroute/create?param1=1¶m2=2 etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With