Tag: ES6-PROMISE
Necesito que la función useProductList se ejecute y finalice todo el proceso antes de que la función randomProduct se ejecute. Por alguna razón, no funciona cuando fetchData es una promesa, por lo que randomProduct no se ejecutará. Incluso intenté sin Promise, nada funcionó. mi hook personalizado “`import { useState, useEffect . . . Read more
¿Cuál es la diferencia entre estas dos promesas? Una se usa en el argumento, la otra afuera. ¿Cuál se prefiere? fetch(API_URL + “films”) .then(response => response.json()) .then(films => { output.innerText = getFilmTitles(films); }) .catch(error => output.innerText = “:(“); fetch(API_URL + “films”) .then(response => response.json() .then(films => { output.innerText = getFilmTitles(films); . . . Read more
Tengo una función auxiliar que utiliza fetch para obtener datos de una API: const callApi = (endpoint: string, method = ‘GET’, body?: string): Promise<response> => { // decide if url is dev or prod const url = getUrl() const headers = new Headers() headers.set(‘infinote-token’, store.infinoteToken as string) const initObject = . . . Read more
Si la conexión se interrumpe, Redis se bloquea. const redis = require(“redis”) // redis no está disponible en localhost const client = redis.createClient({ socket: { connectTimeout: 1000, reconnectStrategy: (r) => r > 5 ? new Error(“mensaje”) : 500 } }); let count = 0; client.on(“error”, () => console.log(++count)) <p>client.connect().catch(() => . . . Read more
Solo cambia la función ABC, ¿cómo puedo obtener la salida en el mismo orden que la función presente en la variable D? He intentado usar async-await pero obtengo la salida como [‘123’, ‘ankit’, ‘345’] debido al evento de tiempo de espera. const A = (dev) => { setTimeout(() => { . . . Read more