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

后端 未结 3 1439
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 10:19

Scenario: We developer are trying to replace a web service (written in C#.Net) with Node.JS Restful API.

Issue: Now we need to hand

相关标签:
3条回答
  • 2020-12-16 11:03

    Simon's answer is no longer valid as restify's queryParser has been moved to the restify-plugins package. The updated solution is

    server.use(require('restify-plugins').queryParser());
    
    0 讨论(0)
  • 2020-12-16 11:06

    You just need to load the query parser plugin like so;

    server.use(restify.plugins.queryParser());
    
    0 讨论(0)
  • 2020-12-16 11:11

    Restify 5 (2017) answer:

    As of restify 5 you can now setup the query parser like this: server.use(restify.plugins.queryParser());.

    If you use this plugin you can access the parsed params in req.query.

    For additional options and information, take a look into the restify documentation: http://restify.com/docs/plugins-api/#queryparser

    0 讨论(0)
提交回复
热议问题