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

153
Visualizações
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then')

I'm using an object oriented chart and setting data according to the scroll position. I'm using d3.csv() to load data with then(), like this:

const chart = new Chart(instatiatechartfunctions);

let dataObj1 = d3.csv('datapath', dataparsefunction);
let dataObj2 = d3.csv('datapath2', dataparsefunction);

let dataArr = [dataObj1,dataObj2];

function init(data){
     chart.setData(data);
    }

let g3 = scrollerfunction().settings()
                           .on('active', function(i){
                                dataArr[i].then(init); //error here
                                });

It's quite complicated for me to include the scroller library along with all the code for the chart, so I hope the above is clear enough. My main issue is that calling init in then() with no () shows the graph but returns the error in the title. when I use the parentheses (then(init())) I get the following error:

Uncaught TypeError: Cannot read properties of undefined (reading '0')

I am using d3.v6 Can anyone help?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Putting .then(init) without the parenthesis is the equivalent to saying .then((array) => init(array)), as in both cases you are giving .then a one-argument function to execute on the return of your promise. If the error then shows up in the title, I guess that there's something going on in that part of the code, but not here.

about 4 years ago · Juan Pablo Isaza Relatório
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