Created
October 12, 2018 05:09
-
-
Save mewben/10020ed59c0249bde74ea1774046c80e to your computer and use it in GitHub Desktop.
Adding delay in nodejs api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const someFunction = async () => { | |
try { | |
// wait 5 sec before sending the response | |
await new Promise(resolve => setTimeout(() => resolve(), 5000)); | |
return res.json({response: 'here'}) | |
} catch (error) { | |
// return error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment