Created
June 21, 2018 09:00
-
-
Save MaraAlexa/9639a6fbc314ce713913eccb22a65140 to your computer and use it in GitHub Desktop.
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
function fetchCatAvatars(userId) { | |
return fetch(`https://catappapi.herokuapp.com/users/${userId}`) | |
.then(response => response.json()) | |
.then(user => { | |
const promises = user.cats.map(catId => | |
fetch(`https://catappapi.herokuapp.com/cats/${catId}`) | |
.then(response => response.json()) | |
.then(catData => catData.imageUrl)) | |
return Promise.all(promises) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment