When working on the server side, I receive a simple JSON file via REST that contains various IDs. Here is an example:
[ {
"_id": "5825a49dasdasdasd8417c1b6d5",
}
"_id": "dfsdfsdf4960932218417c1b6d5",
}
"_id": "23434344960932218417c1b6d5",
},]
To handle this, I have set up the following in the main:
main.post('/..../add', Controller.addEvent);
In the controller, my goal is to retrieve the request and search for these IDs in MongoDB to gather more information about them.
exports.addEvent = function(req, res) {
var collection = db.get().collection('events');
My query now is, if someone sends me the aforementioned JSON file over "localhost:8080/events/add", how should I process this JSON? I specifically need the IDs to conduct a search based on them.
Thank you for your assistance!
----------ADDED------------
I have made progress since then. In my controller, I have implemented the following function:
exports.addevent = function(req, res)
{
var ids = req.body;
console.log(ids);
}
At this point, I am able to retrieve all IDs that were posted using "Postman" from Chrome. The output in the console looks like this:
[ { _id: '5825a49dasdasdasd8417c1b6d5' },
{ _id: 'dfsdfsdf4960932218417c1b6d5' },
{ _id: '23434344960932218417c1b6d5' } ]
Now the question is, how can I access each individual ID separately?