I'm starting to create an webapi with Node Js and Express.
Then the following question came up :
If I have a function that will handle the /
request like:
router.get('/', (req, res, next) => {
pool.query("select * from users").then((data) => {
setTimeout(() => {
res.json(data.rows);
}, 5000);
}).catch((err) => {
res.json({
error: err
});
});
});
Considering that the database query takes longer than expected, will other users be able to request the same route at the same time ? Or will express block it until it has a response to the first request?
**The timeout function inside the then()
block is just to illustrate what I mean.