Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Miguel curiosity #52

wants to merge 3 commits into from

Conversation

gargonmi
Copy link
Collaborator

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

@UlisesGascon UlisesGascon mentioned this pull request Jan 9, 2019
46 tasks
Copy link
Contributor

@UlisesGascon UlisesGascon left a 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!

captura de pantalla 2019-01-15 a las 16 12 06


return new Promise(function(resolve,reject){

let xmlHttp = new XMLHttpRequest();
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ console.log... perdido

resolve (JSON.parse(xmlHttp.responseText));
}
else if (xmlHttp.readyState === 4 && xmlHttp.status === 404) {
console.error("ERROR! 404");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ console.log... perdido

let frecuency = 1000;
async function init() {

const token = "UtXjt0H5jUOdg7OzsNhKrqYgGLUwRu3yC688M13w";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Token expuesto...

}


let sun = 2047;
Copy link
Contributor

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){
Copy link
Contributor

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;
Copy link
Contributor

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++){
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants