Hi, guys i have this code:
app.get("/tema/:search", (req, res, next) => {
res.setHeader("Content-Type", "application/json; charset=utf-8");
var params = [req.params.search]
//var sql = 'SELECT * FROM Topics where topic like ' + keyword;
var sql = `SELECT * FROM Topics WHERE topic LIKE "%${params}%"`;
db.all(sql,params, function(rows, err) {
console.log(sql,params);
rows.forEach(function(row) {
console.log(row.id + ": " + row.topic);
var temp = row.topic;
res.write(temp);
});
});
});
but got the error:
TypeError: rows.forEach is not a function
if i use the ID for call the title of the category this works, so the problem is on the LIKE concatenation, anyone has experience on this?
thanks !