JSFiddle - React, Tailwind, and code Playground
by Lucas Costa
JavaScript
var sql1 = "SELECT * FROM epas_plc WHERE uid = ?";
conn.query(sql1,[id], function(err1, resp1){
console.log(resp1.length);
var rlength = resp1.length;
if(rlength == 1){
res.send({'status' : 'error', 'information' : 'id already exsists'});
} else{
var sql = "INSERT INTO epas_plc (uid, business, contact_no, contact_email, addr_1, addr_2, post_code, gs_unit, timezone) VALUES(?,?,?,?,?,?,?,?,?)";
conn.query(sql,[id, body['business'], body['contact_no'], body['contact_email'], body['addr_1'], body['addr_2'], body['post_code'], body['gs_unit'], body['timezone']], function(error, response){
if(error) res.status(500).send({{'msg' : 'error found'});
res.send({'status' : 'success', 'information' : 'successfully created entry with id: ' + req.body.id});
})
}
});