query string - How to parse/read multiple parameters with restify framework for Node.JS -


scenario: developer trying replace web service (written in c#.net) node.js restful api.

issue: need handle incoming request (we don't have control on it). following format of incoming url:

http://www.website.com/service.aspx?uid=trans001&facebookid=ae67ea324&getdetailtype=full

i able handle url like:

http://www.website.com/service/trans001/ae67ea324/full

i can parse/read parameter above url

code:

var server = require('restify').createserver(); function respond(req, res, next) {     console.log("req.params.uid:" + req.params.uid);     console.log("req.params.facebookid:" + req.params.facebookid);     console.log("req.params.getdetailtype" + req.params.getdetailtype); } server.get('/service/:uid/:facebookid/:getdetailtype', respond); server.listen(8080, function () {     console.log('%s listening @ %s', server.name, server.url); }); 

question: how can read multiple parameters url formatted http://www.website.com/service.aspx?uid=trans001&facebookid=ae67ea324

you need load query parser plugin so;

server.use(restify.queryparser()); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -