es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: ES6-PROMISE

¿Cuál es la diferencia entre usar “then” en un argumento y no usarlo?

¿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

¿De dónde proviene este requisito de una Promesa?

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