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

91
Views
NodeJS not showing full object, only [Object], for response

When sending all documents from the MondoDB database I'm getting the response

data: { list: [ [Object], [Object] ] }

This is the correct number of documents, and they are objects, but I want to know how I can display the entire document, including nested objects, not just the [Object]. How is this possible? Here's my code:

Doc.find({})
            .then((list) => {
                let listToSend = [];

                // push the response data to the array
                for (let i = 0; i < list.length; i++) {
                    listToSend.push(list[i]);
                }

                // send the list once all documents are pushed
                res.send(({ data: listToSend }));
            })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If you want to increase the depth of the inspection output (the default is 2) you can manually call the inspect function (here I used 6 as example):

import { inspect } from 'util'

console.log(inspect(myObject, { depth: 6 }))

Or if you want that to happen all the time by default, you can set the defaultOptions:

import { inspect } from 'util'

inspect.defaultOptions.depth = 6
about 4 years ago · Juan Pablo Isaza Report

0

You can use JSON.stringify, and get some nice formatting

console.log(JSON.stringify(myObject, null, 4));

console.log(JSON.parse(JSON.stringify(myObject)));
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!