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

148
Views
How do I resolve Cannot read properties of undefined (reading 'Fiscal Year')?

I am accessing the data retrieved using an API and I am displaying it like this.

<Grid ><Typography variant="body1">Fiscal Year </Typography></Grid>
<TableContainer style={{width:600,height:170}}> 
{stats?<Table 
sx={{alignItems: "center",
display:""}}
>
{stats['Financial Highlights']['Fiscal Year']?<TableBody>
                             <TableRow hover>
                                 <TableCell align="left"> Fiscal Year Ends</TableCell>
                                 <TableCell align="right">  {stats['Financial Highlights']['Fiscal Year']['Fiscal Year Ends']===null?"N/A":stats['Financial Highlights']['Fiscal Year']['Fiscal Year Ends']}</TableCell>
                             </TableRow>
                             <TableRow hover>
                                 <TableCell align="left"> Most Recent Quarter (mrq)</TableCell>
                                 <TableCell align="right">{stats['Financial Highlights']['Fiscal Year']['Most Recent Quarter (mrq)']===null?"N/A":stats['Financial Highlights']['Fiscal Year']['Most Recent Quarter (mrq)']}</TableCell>
                             </TableRow>
</TableBody>:"Loading"}
</Table> :<div>Loading...</div>}                        
</TableContainer>

But I keep getting "Uncaught TypeError: Cannot read properties of undefined (reading 'Fiscal Year')" despite proper data existing. On doing console.log I can see this. enter image description here

Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I could be wrong but I believe by the time compiler enters stats['Financial Highlights']['Fiscal Year'], your API is still busy fetching the response. I would suggest you add a nullable operator like this

stats?.['Financial Highlights']?.['Fiscal Year']

It will pass this check and render the accurate result once the HTTP call get some data to show.

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!