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

198
Vistas
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 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