Created
June 21, 2018 09:00
-
-
Save MaraAlexa/f4a7ea317bf4ed509b1deca48fbc094b 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