Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentDidMount() {
- axios
- .all([
- axios.get("https://swapi.co/api/people"),
- axios.get("https://swapi.co/api/planets")
- ])
- .then(
- axios.spread(function(peopleRes, planetRes) {
- //... but this callback will be executed only when both requests are complete.
- console.log("People", peopleRes.data);
- console.log("Planets", planetRes.data);
- peopleRes.data.results.map(result => ({
- name: `${result.name}`,
- id: result.id
- }));
- })
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement