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

205
Visualizações
Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'forEach'

here is such a mistake Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'forEach') (anonymous function) http://localhost:3000/portfolio/arbitunity/static/js/main.chunk.js:3059:30 3056 | 3057 | dataset.forEach(exchange => { 3058 | // then iterate over every coin

3059 | exchange.pairs.formatted.forEach(coin => { | ^ 3060 | // map over already processed coins (uniqueCoinsAndPrices) 3061 | // check if entry of said coin already exists 3062 | const found = uniqueCoinsAndPrices.some(item => item.name === coin.name); // if not found, push a new object (inluding coin name) to array View source getUniqueCoinsAndPrices C:/Users/Admin/Desktop/arbitunity-master/src/functions/calculations/getUniqueCoinsAndPrices.js:5 2 | const uniqueCoinsAndPrices = []; 3 | 4 | // iterate over every exchange 5 | dataset.forEach((exchange) => { | ^ 6 | // then iterate over every coin 7 | exchange.pairs.formatted.forEach((coin) => { 8 | // map over already processed coins (uniqueCoinsAndPrices)

enter image description here

    export const getUniqueCoinsAndPrices = (dataset) => {
  const uniqueCoinsAndPrices = [];

  // iterate over every exchange
  dataset.forEach((exchange) => {
    // then iterate over every coin
    exchange.pairs.formatted.forEach((coin) => {
      // map over already processed coins (uniqueCoinsAndPrices)
      // check if entry of said coin already exists
      const found = uniqueCoinsAndPrices.some(
        (item) => item.name === coin.name
      );

      // if not found, push a new object (inluding coin name) to array
      if (!found) {
        uniqueCoinsAndPrices.push({
          name: coin.name,
          id: coin.id,
          priceList: [
            {
              exchange: `${exchange.name}`,
              price: coin.price,
            },
          ],
        });
      }

      // if found -> check at which index,
      // update only the price (add price @ ExchangeXYZ to list)
      // (useless on the first exchange, but needed for comparing data of multiple ones)
      else {
        const index = uniqueCoinsAndPrices
          .map((element) => element.name)
          .indexOf(coin.name);

        uniqueCoinsAndPrices[index].priceList.push({
          exchange: `${exchange.name}`,
          price: coin.price,
        });
      }
    });
  });
  return uniqueCoinsAndPrices;
};

enter image description here

enter image description here

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