Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

351
Vistas
Hello i need to get the fastest response, all successful (which means ignore the rejected) and three first responded

I've already tried to get the fastest response but in chrome toolbar network i see all the responses but not the fastest. Also as i mentioned above I want to get all the successful responses and ignore rejected

const url = 'https://mate-academy.github.io/phone-catalogue-static/api/phones.json';
const detailsUrl = 'https://mate-academy.github.io/phone-catalogue-static/api/phones/';

const getPhones = () => {
  return fetch(url)
    .then(response => {
      if (!response.ok) {
        setTimeout(() => {
          return Promise.reject(new Error('It was an accident'));
        }, 5000);
      }

      return response.json();
    });
};

const getFirstPhoneDetails = (arrId) => {
  return Promise.race(arrId.map(id =>
    fetch(`${detailsUrl}${id}.json`)));
};

getPhones()
  .then(phones => {
    const ids = phones.map(p => p.id);

    return getFirstPhoneDetails(ids);
  })
  .catch(error => {
    console.warn(error);
  });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda