Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 22x 1x 2x 2x 2x 2x 1x | import axios from 'axios'; import { SWAPIEntity } from 'types'; import { getEntityDataFromUrl, getImageUrl } from 'utils'; const populateEntityRelationships = async (urls: string[]) => { const results = await Promise.all( urls.map(async url => { const { id, entity } = getEntityDataFromUrl(url); const { data } = await axios.get<SWAPIEntity>(url); const formatedData = { id, entity: entity, title: (data.name || data.title)!, image: getImageUrl(entity, id), }; return formatedData; }) ); return results; }; export { populateEntityRelationships }; |