I'm new with SQLite and Node.js and so far the application is able to send some data to the front-end. The problem is that it sends only the first row from the table and it should send all the data.
This is the code so far:
var express = require('express');
var router = express.Router();
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('./db/my_db.db');
router.get('/', function (req, res, next) {
db.serialize(function () {
db.each('SELECT id, name, surname FROM Customers', function (
err,
row
) {
res.send(row);
});
});
db.close();
});
module.exports = router;
It seems that isn't enough to insert res.send() inside db.each() because it does the sending only for the first column.
How can it be done for all the data from that table?