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

275
Views
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 answers
Answer question

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 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!