Skip to content

Instantly share code, notes, and snippets.

@mewben
Created October 12, 2018 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mewben/10020ed59c0249bde74ea1774046c80e to your computer and use it in GitHub Desktop.
Save mewben/10020ed59c0249bde74ea1774046c80e to your computer and use it in GitHub Desktop.
Adding delay in nodejs api
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