Iam new in nodejs, i have a query regarding inserting values in mysql.i have made connection with mysql and now my requirement is to fetch data from query url which i have already done by node js parser.By below code-:
app.get('/insertData',function(req,res){
var url_parts = url.parse(req.url, true);
var query = url_parts.query;
**var id** = req.query.id;
console.log(id);
connection.query("insert into otps (from_user_id,to_user_id,otp,is_company,status,created_on) values (**'id'**,'2345','1','2','2018-04-04 00:00:00')",function(err,result){
if(!!err){
console.log(err);
res.send('Error in inserting');
}
else{
res.send('Successfully Insertion');
}});});
The problem is when iam sending that parse value (id) to my sql table,then null is getting inserted in the table.So how can i save a value from query url to db.
Query Url=http://localhost:1337/insertData?id=20
Thanks enter code here