Currently, I am in the process of creating a set of routes. Below are some examples:
/
- This route should render the home page template
/items
- This route should display the items page template
/items/weeARXpqqTFQRg275
- This route is set to return an item from MongoDB with the given _id
The above examples illustrate what I am aiming to accomplish in this project
Router.route('items/:_id', function () {
var item = return myItems.find(:_id);
this.render(item);
});
[update - resolved]
I was able to solve this issue by utilizing Router.map
on the server side instead of Router.route
Router.map(function () {
this.route('post', {
path: 'items/:_id',
where: 'server',
action: function(){
var id = this.params._id;
var json = myItems.findOne({_id: id});
this.response.setHeader('Content-Type', 'application/json');
this.response.end(JSON.stringify(json, null, 2));
}
});
});