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

131
Views
Trying to construct an array from a known map function

I trying to construct a docs array that would work on docs.maps() function below. However when I run it I get

TypeError: Cannot read property 'uuid' of undefined

If I do

console.log(docs[1]['_source'].uuid);

I get 2 as expected.

Question

Can anyone figure out why the map function can't access uuid but console.log() can?

const docs = [{'_id': 1},{'_source': {'uuid': 2}},{'_source': {'@timestamp': 3}}];

const description = dedent`
================================================
${
  docs.map((element) => [
    `Log entry ID: ${element['_id']}`,
    `UUID: ${element['_source'].uuid}`,
    `Timestamp: ${element['_source']['@timestamp']}\n`,
  ].join('\n')).join('--------------------\n')
}
`;

console.log(description);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to structure like so

const docs = [{'_id': 1,'_source': {'uuid': 2,'@timestamp': 3}}];
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!