Home Unable to send object in Express response
Reply: 0

Unable to send object in Express response

user546
1#
user546 Published in April 22, 2018, 12:45 am

I'm trying to send all the data from my database back using res.send, but it's throwing me an error. On my frontend, I'm calling the endpoint select and trying to return all rows and data within the database.

app.get('/select', function (req, res) {
    con.query('SELECT * FROM Contracts', function (err, rows, fields) {

    if (err) {
      console.log(`Error: ${err}`);
    }

    for (var i = 0; i < rows.length; i++) {
      var row = rows[i];
      res.send(row);
    }
  })
});
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309433 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO