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

105
Views
Get nested data from Firebase Firestore

Here is how I get the data:

enter image description here

Currently when I console.log(snapshotData.data); I get an array of this:

enter image description here

what I want to get is editorState, blocks, 0, text. I tried to get it using snapshotData.data.editorState.blocks.[0].text, and snapshotData.data.editorState.blocks.0.text and it didn't work

again, I want to get this:

enter image description here

On Firestore it's says: editorState is map, blocks -> array, 0 -> map, text -> string

enter image description here

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

0

Try

// if blocks is an Array
snapshotData.data.editorState.blocks[0].text

or

// if '0' is a key corresponding to the smaller object
snapshotData.data.editorState.blocks["0"].text

Update

According to the screenshot uploaded, blocks is actually an array containing one single object.

You should use the first code block I provided, i.e.

snapshotData.data.editorState.blocks[0].text
about 4 years ago · Juan Pablo Isaza Report

0

Fixed by using optional chaining

  console.log(snapshotData?.data?.editorState?.blocks[0]?.text);
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!