I'm adding a pagination in my product list. But I kept having error:
console.log(data.rows);
^
Here's my js file that's query-ing in my database:
list: (client, filter, callback) => {
const productListQuery = `
SELECT *
FROM products
ORDER BY id
`;
client.query(productListQuery, (req, result)=>{
console.log(result.rows);
callback(result.rows);
});
Here's my router.get in my server.js:
app.get('/products', function (req, res, next) {
Product.list(client, {limit: 8}, {offset: (req.query.p - 1) * 8}, {
}, function (products) {
res.render('/client/product-list', {
products: products,
title: 'Products',
pagination: {
page: req.query.p || 1,
limit: 8,
n: req.query.p || 1
}
});
});
});