Encountering an issue while attempting to send raw data as parameters in express. Specifically, there is an error occurring at the 'fields' variable...
function getWithQuery(req,res){
console.log(req.params);
var query = {name: new RegExp(name, 'i')};
var fields = {"_id","name"};//i tried {_id, name}; and {'_id', 'name'}
var maxRecs = 10;
var sort = {name};
dataService.getWithQuery(query, fields, maxRecs, sort)
.then(function(data){
if (data){
res.send(data);
}else {
res.sendStatus(404).send("Doc dont exists");
}
})
.catch(function (err){
console.log("doc dont exists" + err);
res.status(500).send(err);
});
}
The following error is being thrown...
var fields = {"_id","name"};
^
SyntaxError: Unexpected token
Please provide suggestions on how to address this issue...thank you in advance