Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda