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

122
Vistas
Javascript List of List only Interpreted within function scope

I am trying to use the node binance api to pull candlestick data for some cryptocurrency data for the last 24 hours. The following is my code;

export function graph(name) {
  return binance.candlesticks(name + "USDT", "1h", function(error, ticks) {
    let points = [];
    for (let i = 1; i <= 25; i++) {
      let last_tick = ticks[ticks.length - 26 + i];
      let [time, open, high, low, close, volume, closeTime, assetVolume, trades, buyBaseVolume, buyAssetVolume, ignored] = last_tick;
      let temp = [time, Number(open), Number(high), Number(low), Number(close)];
      points.push(temp);
    }

    console.log(points) //Prints a list of lists of numbers correctly
    return points

  });
}
console.log(graph("BNB")) // Prints undefined

As commented, when the data is loaded within the function into 'points' using the for loop, I can operate and print it just fine. However, whenever I actually call the function to do something it returns an undefined. When checking typeof, within the function it returns 'object' whereas outside it returns undefined again. Any guidance is appreciated.

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