using Express (NodeJS), is there a way to save the details of a request so that the response will be done in a later time? (basically, leaving the request hangin for the response). without using setTimeout() or sleep or any other delay.
for example if this is my function:
function(req, res) {
var data = req.body;
setTimeout(function() {
res.json(data);
}, 3000);
}
is it possible to use (req, res) objects outside that function scope?
Yes, you can do it via setTimeout
function(req, res) {
var data = req.body;
setTimeout(function() {
res.json(data);
}, 3000);
}