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

150
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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