I have a node js application that has two GET requests, say for example - test and delay,
var express = require("express");
var app = new express();
app.use('/', express.Router());
app.get('/delay', function (req, res) {
for (var i = 0; i < 500000; i = i + 0.0001) {
let r = 'r';
}
res.json({ 'message' : 'delay message'});
})
app.get('/test', function (req, res) {
res.json({ 'message': 'hello world' });
})
app.listen(1337);
The delay method executes and produces a delayed output, like after around 6-7 seconds, whereas the test method produces the output immediately.
But while testing in Postman, if i run delay method and before its completion if i run test, then the output of test does not appear until delay is completed. I get the output of test only after delay is completed.
How to make these two requests run parallely, independent of one another???
P.S: I have also tried router (express.Router()), but still it is the same.
Thanks!