Calling already defined routes in other routes in Express NodeJS

后端 未结 5 1535
傲寒
傲寒 2020-12-29 20:11

I am writing a web app in node.js using Express. I have defined a route as follows:

app.get(\"/firstService/:query\", function(req,res){
    //trivial exampl         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-29 20:48

    You can use run-middleware module exactly for that

    app.runMiddleware('/firstService/query',function(responseCode,body,headers){
         // Your code here
    })
    

    More info:

    • Module page in Github & NPM;
    • Examples of use run-middleware module

    Disclosure: I am the maintainer & first developer of this module.

提交回复
热议问题