I have an expressjs post route that can take few minutes to finish. The problem is that after some time, the client will try to send a post again. How can I do to make sure the client waits for the response?
My route looks like this:
router.post("/merge", (req: Request, res: Response, next) => {
var timer = setInterval(()=>{
// Check something that can take few minutes here
// Tell the client to wait!
if(completed){
clearInterval(timer);
res.end('completed');
}
if("error"){
res.status(500).send("error");
}
}, 5000);
})