Why findOne return 2 result?

i try to set helpers like this

room: ()=> {
	var id = FlowRouter.getParam('id');
	return Rooms.findOne({_id: id});

when i check with console.log it show 2 result one of them is undefined it cause an error when i try to access it property.
any advice? i very newbie here

You’re probably seeing undefined first, then the actual object? If so that’s normal behavior.

When the page loads it will run the helper function as soon as possible, by then the subscription might not be ready so there is no data in the Rooms collection, thus it can’t find anything. As soon as the subscription is ready the helper will rerun and now return the correct data object.

1 Like

thank nlammertyn
now i found on youtube about template level subscriptions is that a right way to solve this?

There’s nothing to solve really, this is normal. Doing template lever subscriptions doesn’t change that at all.
Does it give you any problems? There’s always ways to work around it if it does.

nothing big just it kind of annoying when see error on console
now i use template level subscriptions so i can use Template.subscriptionsReady it seem to fix my problem :slight_smile:

1 Like