Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

347
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda