我正在使用Express在node.js中编写一个Web应用程序.我已经定义了如下路线:
app.get("/firstService/:query", function(req,res){
//trivial example
var html = "<html><body></body></html>";
res.end(html)
});
Run Code Online (Sandbox Code Playgroud)
如何从快递中重用该路线?
app.get("/secondService/:query", function(req,res){
var data = app.call("/firstService/"+query);
//do something with the data
res.end(data);
});
Run Code Online (Sandbox Code Playgroud)
我在API文档中找不到任何内容,宁愿不使用像"请求"这样的其他库,因为这看起来很笨拙.我想尽可能保持我的应用程序模块化.思考?
谢谢