[RESOLVED] FlowRouter/BlazeLayout: Deliver wrong data?

Hi I’m new in Meteor and starting to build my first Meteor App

After reading several topic, I decided to use FlowRouter/BlazeLayout. I still confused how to deal with data context

I have a list of dummy post. I name it rhid. Here’s the screenshot:

I click the dummy post The Amazing Mars Moon Race. It deliver the right path with wrong data as screenshot below:

This apply to all my dummy posts. No error in chrome and terminal console.

My router:

FlowRouter.route('/rhid', {
  action: function () {
    BlazeLayout.render('layout', { top: "top", main: "rhidList", bottom: "bottomRhid"  });
  }
})

FlowRouter.route('/rhid/:id', {
  name: 'rhidQuote',
  action: function () {
    BlazeLayout.render('layout', {  top:"top", main: "rhidQuote", bottom: "bottomRhid" });
  }
})

Here’s rhidQuote’s template:

<template name="rhidQuote">
	<a href="{{rhids._id}}/read">
		<img class="ui fluid image" src="/uploads/{{rhids.quote}}">
	</a>
</template>

Here’s rhid’s helper:

Template.rhidQuote.helpers({
	rhids: function () {
		return Rhids.findOne();
	}
});

I hope someone could give me some clues what I’m missing

Thanks you very much. Appreciated for your help

Try to add a query to this findOne(). Basically, try to get the data id from the URL and use it for findOne().

Hi arunoda, thanks for taking your time helping me!

When I use this:

Template.rhidQuote.helpers({
	rhids: function () {
		return Rhids.findOne({_id: FlowRouter.getParam('_id')});
	}
});

I got this result:

It seems, the data couldn’t be fetched

Here’s the right data should deliver:

{
	"_id" : "eqtKSEgh7aeQd7vPM",
	"title" : "The Amazing Mars Moon Race",
	"summary" : "To the moons and back! Race in space with this fun adventure.",
	"description" : "Spend the day in the Buck Rogers way - racing from the surface of Mars against a talented field of pilots. Be the first to touch down on Phobos, grab the next clue, and then head over to Deimos for the final clue. \n\nThe winner will be the first space racer to return to the hidden finish line on Mars!",
	"quote" : "moon-races.jpg",
	"audio" : "Ryan-Farish.mp3"
}

It should be: FlowRouter.getParam('id')

1 Like

Ah stupid me!

Thank you Arunoda. I mean Professor!

2 Likes