I have attached my postman error message.
My server.js
var sql = 'INSERT INTO products (productName, description, category,brand, expiredDate, manufacturedDate, batchNumber, unitPrice,quantity, createdDate) VALUES (?,?,?,?,?,?,?,?,?,?)'
var parms = [productName, description, category,brand, expiredDate, manufacturedDate, batchNumber, unitPrice,quantity, createdDate]
db.run(sql,parms,function(err, result){
if (err){
res.status(400).jason({"error":err.message})
return;
}else{
res.json({
"message":"success",
'data':res.body,
"id":this.lastID
})
}
My database.js
let db = new sqlite3.Database(DBSOURCE,(err) => {
if(err){
console.error(err.message)
throw err
}else{
console.log(`Connected to the SQlite Data base')
db.run( 'CREATE TABLE products (
id INTEGER PRIMARY KEY AUTOINCREMENT,
productName text,
description text,
category text,
brand text,
expiredDate text,
manufacturedDate text,
batchNumber INTEGER,
unitPrice INTEGER,
quantity INTEGER,
createdDate text
)`, (err) => {
if (err){
// table already created
} else {
var insert = 'INSERT INTO products' (productName, description, category,brand, expiredDate, manufacturedDate, batchNumber, unitPrice,quantity, createdDate)
db.run(insert,["white basmathi rice", "whitebasmathiaaaa", "Rice", "CIC", "2033.10.3", "2021.05.15", 515, 333, 2500, "2021.09.10"])
}
}
)
}
});
Thanks for helps.