this my code
app.get('/status',function ( req,res) {
var data = {
"error": 1,
'data status': ""
};
connection.query("SELECT * from status", function (err, rows, fields) {
if (rows.length != 0) {
data = rows;
console.log(data);
res.json(data);
} else {
data["Data status"] = '0';
res.json(data);
}
})
});
I had a problem I try to change the json object
[{"id_status":5,"pin_arduino":1,"status":0}]
I will eliminate be
{"id_status":5,"pin_arduino":1,"status":0}
JSON.parsenot work?