Solution: Erick Noiztbander#14
Open
Noiztbander wants to merge 4 commits intoassembler-institute:mainfrom
Open
Conversation
Ethan-Alfaro
reviewed
Jun 1, 2021
Ethan-Alfaro
left a comment
There was a problem hiding this comment.
Por lo general esta bastante bien, pero yo quitaría todos los comentarios innecesarios que tienes, y dejaría solo los explicativos, pero buen trabajo
| import LocationPage from "./pages/LocationPage"; | ||
|
|
||
| function App() { | ||
| return <Home />; |
There was a problem hiding this comment.
El primer return creo que no haría falta.
Author
There was a problem hiding this comment.
No men hahaha las lineas en rojo son cosas que se han eliminado pero que quedan registradas dentro del git como un "cambio". osea que ese return, en verdad yo no lo tengo en mis lineas. si sale en rojo es precisamente porque esta eliminado ehhehe
Comment on lines
+1
to
+26
| import axios from "axios"; | ||
|
|
||
| export function makeApi() { | ||
| return axios.create({ | ||
| baseURL: "https://rickandmortyapi.com/api", | ||
| timeout: 1000, | ||
| }); | ||
| } | ||
|
|
||
| export function getEpisodes(page = 1, api = makeApi()) { | ||
| return api.get(`/episode?page=${page}`); | ||
| } | ||
|
|
||
| export function getEpisode(episodeId, api = makeApi()) { | ||
| return api.get(`/episode/${episodeId}`); | ||
| } | ||
| export function getCharacters(characterId, api = makeApi()) { | ||
| return api.get(`/character/${characterId}`); | ||
| } | ||
| export function getLocation(locationId, api = makeApi()) { | ||
| return api.get(`/location/${locationId}`); | ||
| } | ||
|
|
||
| export function getUrl(url, api = makeApi()) { | ||
| return api.get(url); | ||
| } |
Comment on lines
+46
to
90
| async loadEpisode(episodeId) { | ||
| // console.log(this); | ||
| /* | ||
| * Aquí lo que hacemos es encapsular dentro de DATA, toda la informacion | ||
| * del episodio que nos traemos del API | ||
| */ | ||
|
|
||
| try { | ||
| const { data } = await getEpisode(episodeId); | ||
| /* | ||
| * Esta funcion nos llama a otra funcion que dentro nos devuelve un Array mediante un map | ||
| * en la siguiente variante, haremos lo mismo pero de forma manual (NO RECOMENDABLE) | ||
| */ | ||
| // eslint-disable-next-line compat/compat | ||
| const characterResponse = await Promise.all( | ||
| makePromises(data.characters), | ||
| ); | ||
|
|
||
| // const promises = data.characters.map((character) => axios.get(character)); | ||
|
|
||
| /* | ||
| * Ademas, axios, siempre nos devuelve las propiedades que necesitamos dentro de un objeto y dentro del objeto en DATA. | ||
| * para solucionarlo, debemos recorrer cada objeto, sacando ese DATA y guardandolo | ||
| * en un nuevo array con ese contenido. | ||
| */ | ||
| const characters = characterResponse.map((character) => character.data); | ||
|
|
||
| this.setState({ | ||
| hasLoaded: true, | ||
| episode: data, | ||
| characters: characters, | ||
| }); | ||
|
|
||
| // console.log(data); | ||
| // console.log(characterResponse); | ||
| // console.log(promises); | ||
| // console.log(characters); | ||
| } catch (error) { | ||
| this.setState({ | ||
| hasLoaded: true, | ||
| hasError: true, | ||
| errorMessage: error.message, | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Creo que toda esta parte la podrias haber echo de manera mas sencilla usando axios
| import { getEpisodes } from "../../api"; | ||
|
|
||
| import Layout from "../../components/Layout"; | ||
| // import EpisodeCard from "../../components/EpisodeCard"; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.