Created
March 2, 2020 10:12
-
-
Save jwchang0206/e6d89705720fad6e77082a3318372923 to your computer and use it in GitHub Desktop.
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
import axios, { CancelToken } from 'axios'; | |
const source = CancelToken.source(); | |
setTimeout(async () => { | |
const { data } = await axios.get(url, { cancelToken: source.token })); | |
alert(JSON.stringify(data)); | |
}, 5000); | |
source.cancel(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment