Created
October 17, 2019 19:33
-
-
Save robertoandres24/9ec3bcc3357f925c984422ec3fe94491 to your computer and use it in GitHub Desktop.
promise all
This file contains hidden or 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
async function getfbProfile(token) { | |
try { | |
const user = axios.get('https://graph.facebook.com/me', { | |
params: { | |
access_token: token, | |
fields: 'picture,accounts', | |
}, | |
}); | |
const pages = Promise.all(user.data.accounts.data.map(({ id }) => { | |
return axios.get(`https://graph.facebook.com/${id}`, { | |
params: { | |
access_token: token, | |
fields: 'picture,name', | |
}, | |
}); | |
})); | |
const fbProfile = await Promise.all([user, pages]); | |
debug(fbProfile); | |
} catch (err) { | |
debug(err.stack); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment