The code :- app.post('/BSK', urlencodedParser, function(req, res){
client.query(Select * from public."mst_bskServices" where "Name" = '${req.body.Service}'
, (err, result)=>{
if(!err){
res.end(JSON.stringify(result.rows));
console.log(JSON.parse(JSON.stringify(result.rows)));
}
else{ console.log(err.message) };
});
client.end;
});
This is the response :- [ { id: 1, Name: 'Aikyashree
',
statusapiurl: 'https://serv1.wbmdfcscholarship.org/Api/bsk_submit_report
',
statusapidoctype: 'DEMO '
} ]
CodePudding user response:
If you want to access id from your response you can perform:results[0].id;
And name: results[0].name
And if you have multiple records to access records use for loop over the result key as follows:
for (var a = 0; a < Object.keys(result).length; a ) { result[a].id result[a].name }