Skip to content

Instantly share code, notes, and snippets.

@maxjing
Created January 15, 2019 00:13
Show Gist options
  • Save maxjing/4f2acd7775bf3d39fde38ea6899ca4b6 to your computer and use it in GitHub Desktop.
Save maxjing/4f2acd7775bf3d39fde38ea6899ca4b6 to your computer and use it in GitHub Desktop.
axios mutiple request promise all
_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