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

121
Visualizações
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 à 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