-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miguel curiosity #52
base: master
Are you sure you want to change the base?
Miguel curiosity #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esto es una constante ;-) Documentación
xmlHttp.onreadystatechange = function() { | ||
|
||
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) { | ||
console.log("respuesta"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve (JSON.parse(xmlHttp.responseText)); | ||
} | ||
else if (xmlHttp.readyState === 4 && xmlHttp.status === 404) { | ||
console.error("ERROR! 404"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let frecuency = 1000; | ||
async function init() { | ||
|
||
const token = "UtXjt0H5jUOdg7OzsNhKrqYgGLUwRu3yC688M13w"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
|
||
let sun = 2047; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puedes hacer sun--;
divRow = document.querySelector('#cartas'); | ||
function pintarfotos(currentValue){ | ||
|
||
for (i = 0 ; i < currentValue.photos.length ; i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tienes justficación para este for
, el contexto te deja usar un forEach
El ejercicio del curiosity con Async functions y promesas.
(todos los soles me ofrecen fotos)