SOLVED: Accessing a single document


#1

Here’s my repo https://github.com/tenzan/sb2-mongo-mysql

I want to access a particular document at http://localhost:3000/locations/QE4psYj9KLyQkBa5P

Template for this page is location_page.html:

<template name="locationPage">
    <div class="location-page page">
        {{> locationItem}}
        <h3>{{code}}</h3>
        <h3>{{name}}</h3>
    </div>
</template>

It shows nothing at the moment. I assume I will need to make a corresponding in the location_page.js but can’t figure out how it should look like.

Thanks in advance.


#2

This is solved by removing waitOn part in the router.js as I was refactoring from another code.

Router.route('/locations/:_id', {
    name: 'locationPage',
    waitOn: function () {
        return Meteor.subscribe('comments', this.params._id);
    },
    data: function () {
        return Locations.findOne(this.params._id);
    }
});