Hi everyone i am using React-Native front end with Node.js with Mysql back end ,
I am counting the number of rows with particular id everything is good in the query, i got the value from the query but i am unable to use the value because it is in the the form of
"res_Count":[{"count(*)":2}] .
function i want it in the string format .
Once check my query and the result
router.get('/get_Following_Count/:user_id', (req, res, next) => {
connection.query("SELECT count(*) FROM followers WHERE followers.follower_id=? ORDER BY id DESC ", [req.params.user_id], (err, results, fields) => {
if (!err) {
// res.send(rows);
following_Count = JSON.parse(JSON.stringify(results));
return res.json({ "status": 200, "error": null, "res_Count": following_Count });
} else {
console.log(err);
return res.status(404).send('Sorry user_id does not exits');
}
})
});
Output:
{"status":200,"error":null,"res_Count":[{"count(*)":2}]}
Please give me any suggestions to change the count(*) value