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

132
Views
Typescript error 1005. ':' expected when trying to access returned JSON data

I'm returning data from an API call. The returned JSON looks like this:

{
    "data": {
        "getAccountDetails": {
            "cars": [
                {
                    "rental": true,
                    "id": "abcdefg"                    
                }
            ]
        }
    }
}

I'm trying to console log the boolean rental (true or false). I keep getting this typescript error: ':' expected. ts(1005. This is how I'm console logging:

console.log(data?.getAccountDetails?.cars?[0]);

How can I resolve this error?

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

0

You are missing a dot.

console.log(data?.getThermostatDetails?.thermostats?.[0]);

It's ?. even when you want to access a property via square brackets.

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!