Open
Conversation
Contributor
UlisesGascon
left a comment
There was a problem hiding this comment.
Feedback
- Me gusta tu enfoque! Se nota que ya te vas familiarizando con las asincronía y con ES6+
- La recursividad debería gestionarse dentro de la función
NasaRequest - Siempre esta bien dar un ultimo vistazo para no dejarnos
tokens,console.logs... - En resumen... ¡Gran trabajo! 🌟 🌟
👏 👏 👏 Bravo por esta pedazo de implementación con HTML y CSS!
|
|
||
| return new Promise(function(resolve,reject){ | ||
|
|
||
| let xmlHttp = new XMLHttpRequest(); |
| xmlHttp.onreadystatechange = function() { | ||
|
|
||
| if (xmlHttp.readyState === 4 && xmlHttp.status === 200) { | ||
| console.log("respuesta"); |
Contributor
There was a problem hiding this comment.
| resolve (JSON.parse(xmlHttp.responseText)); | ||
| } | ||
| else if (xmlHttp.readyState === 4 && xmlHttp.status === 404) { | ||
| console.error("ERROR! 404"); |
Contributor
There was a problem hiding this comment.
| let frecuency = 1000; | ||
| async function init() { | ||
|
|
||
| const token = "UtXjt0H5jUOdg7OzsNhKrqYgGLUwRu3yC688M13w"; |
| } | ||
|
|
||
|
|
||
| let sun = 2047; |
Contributor
There was a problem hiding this comment.
Esto debería evitarse... no deberías tener los valores de forma global
| let url = `https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=${sun}&api_key=${token}` | ||
|
|
||
| const currentValue = await NasaRequest(url,frecuency); | ||
| if (currentValue.length === 0){ |
Contributor
There was a problem hiding this comment.
Esta recursividad deberia ser dentro de la función NasaRequest. Ver solución
| const currentValue = await NasaRequest(url,frecuency); | ||
| if (currentValue.length === 0){ | ||
| console.log("currentValue:", currentValue.photos); | ||
| sun -=1; |
| divRow = document.querySelector('#cartas'); | ||
| function pintarfotos(currentValue){ | ||
|
|
||
| for (i = 0 ; i < currentValue.photos.length ; i++){ |
Contributor
There was a problem hiding this comment.
No tienes justficación para este for, el contexto te deja usar un forEach
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.

El ejercicio del curiosity con Async functions y promesas.
(todos los soles me ofrecen fotos)