hi I am new to compound Js.
In compound js, I am retrieving data from back end as data was in json format.
In my controller I wrote code to retrieve data by passing id like this-
action(function teamforsportsid(req, res){
return Team.find(req.params.id, function(err, team){
if(!err) {
return send(team[0]["_id"]);
}else {
return console.log(err);
}
});
});
In this team[0]["_id"] I got particular id.
In place of team[0]["_id"], I used team[0]["first_name"] and I didnt get the name...
My json will be like this...
[
{
"_id": "510b51ff6ee1f5ab2800001f",
"first_name": "Pittsburgh"} ]
Is there any other way to retrieve data in controller?
Use this-
action(function teamforsportsid(req, res){
return Team.find(req.params.id, req.params.first_name, function(err, team){
if(!err) {
return send(team[0]["_id"], team[0]["first_name"]);
}else {
return console.log(err);
}
});
});