Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barisere/79561a8f2de981414731e3b13c2318fa to your computer and use it in GitHub Desktop.
Save barisere/79561a8f2de981414731e3b13c2318fa to your computer and use it in GitHub Desktop.
router.delete('/resource/:id', (req, res) => {
const id = req.params.id;
deleteRequestMap.set(id, deleteResourceOnTimeout(id, 10000));
res.status(200).json({ cancelId: deleteRequestMap.get(id) }).end();
});
router.get('/resource/:id/cancelDelete', (req, res) => {
const id = req.params.id;
clearTimeout(deleteRequestMap.get(id));
res.status(200).json({ message: 'Request cancelled' }).end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment