Created
October 31, 2021 19:08
-
-
Save coderkan/11f47a8187a2e74bd762ec35d379840e to your computer and use it in GitHub Desktop.
axios-all-example
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
let reqOne = axios.get('https://api.github.com/repos/stedolan/jq/commits'); | |
let reqTwo = axios.get('https://api.github.com/repos/coderkan/spring-boot-redis-cache/commits'); | |
axios.all([reqOne, reqTwo]).then(axios.spread((…res) => { | |
console.log(res[0]); | |
console.log(res[1]); | |
// you can also set your states. | |
this.setState( | |
{ | |
reqOneCount: res[0].data.length, | |
reqTwoCount: res[1].data.length | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment