Created
June 30, 2018 03:22
-
-
Save samzhao/9c61eb0f6db39960b8c30c95fb4d0a88 to your computer and use it in GitHub Desktop.
Delay with async/await
This file contains hidden or 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 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