Skip to content

Instantly share code, notes, and snippets.

@samzhao
Created June 30, 2018 03:22
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 samzhao/9c61eb0f6db39960b8c30c95fb4d0a88 to your computer and use it in GitHub Desktop.
Save samzhao/9c61eb0f6db39960b8c30c95fb4d0a88 to your computer and use it in GitHub Desktop.
Delay with async/await
const delay = time =>
new Promise(resolve => setTimeout(resolve, time));
const sendRequest = async () => {
await delay(1000);
return axios.get(API_URL);
}
// request fires after 1 second
sendRequest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment