diff --git a/3-fetch-api-ajax/fetch.html b/3-fetch-api-ajax/fetch.html new file mode 100644 index 0000000..5bfc9a4 --- /dev/null +++ b/3-fetch-api-ajax/fetch.html @@ -0,0 +1,13 @@ + + + + + + + Fetch + + + + + + \ No newline at end of file diff --git a/3-fetch-api-ajax/fetch.js b/3-fetch-api-ajax/fetch.js new file mode 100644 index 0000000..6721466 --- /dev/null +++ b/3-fetch-api-ajax/fetch.js @@ -0,0 +1,17 @@ +async function personajes() { + let data = await fetch("https://swapi.dev/api/people/"); + let response = await data.json(); + return response.results; +} + +(async () => { + let personajeslista = await personajes(); + + const groupBygender = personajeslista.reduce((group, person) => { + const { gender } = person; + group[gender] = group[gender] ?? []; + group[gender].push(person.name); + return group; + }, {}); + console.log(groupBygender); +})(); \ No newline at end of file