Skip to content

Instantly share code, notes, and snippets.

@coderkan
Created October 31, 2021 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderkan/11f47a8187a2e74bd762ec35d379840e to your computer and use it in GitHub Desktop.
Save coderkan/11f47a8187a2e74bd762ec35d379840e to your computer and use it in GitHub Desktop.
axios-all-example
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