Created
January 15, 2019 00:13
-
-
Save maxjing/4f2acd7775bf3d39fde38ea6899ca4b6 to your computer and use it in GitHub Desktop.
axios mutiple request promise all
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
_getAllStaticRDCData = () => { | |
var self = this; | |
axios | |
.all([ | |
this.getStaticRDCData("hp"), | |
this.getStaticRDCData("srp"), | |
this.getStaticRDCData("ldp") | |
]) | |
.then( | |
axios.spread(function(hp, srp, ldp) { | |
console.log("hp => "); | |
console.log(hp); | |
console.log("srp => "); | |
console.log(srp); | |
console.log("ldp => "); | |
console.log(ldp); | |
self.setState({ | |
hpData: hp.data.results, | |
srpData: srp.data.results, | |
ldpData: ldp.data.results | |
}); | |
}) | |
) | |
.catch(error => { | |
console.log(error); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment