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

280
Views
cómo recuperar los valores en [object Object] javascript

Tengo esto en mi 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) })

y en mi 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>

pero cuando registro kk , devuelve [object Object] , y lo mismo cuando lo pongo en la pantalla, como puede ver que estoy haciendo arriba. ¿Cómo puedo arreglar esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

tu puedes hacer

 Object.keys(kk)

para obtener las claves del objeto y luego acceder a los valores usando las claves.

respuesta mas completa

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

también puedes usar JSON.stringify(kk)

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!