Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda