我对NodeJS
和网络开发都很陌生。
我使用快速Web服务器,而requestter.on是ZMQ listener
。
如何访问相应app.post()方法的相应res对象?我通过将requester.on-listener移动到任何app.post方法来尝试它,但它会导致不良的副作用。
app.post("/first", function (req, res) {
var reqStringFirst
requester.send(reqString);
//the app gets a response immediately after the send() call
});
app.post("/second", function (req, res) {
var reqStringSecond
requester.send(reqString);
//the app gets a response immediately after the send() call
});
requester.on("message", function (reply) {
var replyJSON = new TextDecoder("utf-8").decode(reply);
// and here I want to use the respective res
// object to render different pages depending on the replyJSON content.
//like this line:
res.render("pages/serviceDetails", {replyJSON});
});
最亲切的问候