Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!