I need to handle requests one-by-one in javascript.
For example, we have 10 simultanious POST requests to the route /wall/createPost
and following code:
app.post('/wall/createPost', (request, response) => {
...
queue.push(request);
... somehow await to solve this and after make response.send('ok') ...
});
I need to make some queue to handle simillar tasks one-by-one. For example, loop.
let queue = [];
setInterval(() => {
const dataToHandle = queue[0];
...
queue.shift();
}, 1000);
How to await solvation of the task inside app.post
callback?