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

281
Visualizações
how to retrieve the values in [object Object] javascript

I have this on my backend:

 app.get('/dashboard', async(req, res) => {
  
  const customers = await stripe.customers.list();

  customers.data.forEach(customer => {
    // console.log(customer.metadata);
  });

  res.render('dashboard.ejs', {customer: customers})
  console.log(customers)

})

and on my front-end (ejs):

  <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th>NAME</th>
        <th>EMAIL</th>
        <th>ACTIONS</th>
      </tr>
    </thead>
    <tbody>
      <% if(customer.data.length){ 
        for(var i = 0;i < customer.data.length;i++) { %>
      <tr>
          <script>
              let kk = JSON.stringify('<%=customer.data%>')
              console.log(kk)
          </script>
      <td><%=customer.data%></td>
         <% }
        }else{ %>
            <p>err</p>
        <% } %>
    </tr>
    </tbody>
  </table>

but when I log kk, it returns [object Object], and the same when I put it out to the screen, as you can see I am doing above. How can I fix this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you can do

Object.keys(kk)

to get the keys of the object and then access values using the keys.

more complete answer

for key in Object.keys(kk) {
   value = kk[key];
   console.log(value);
}

you can also use JSON.stringify(kk)

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