Hi,
I’m experiencing an issue where this.data
in my template’s onCreated
callback is wrapped in an extra value
object, which shouldn’t be the case.
Here’s my router setup:
javascript
Router.route('/myRoute', {
name: 'myRoute',
data() {
return MyCollection.findOne();
},
});
And in my template:
javascript
Template.myRoute.onCreated(function () {
console.log(this.data);
// Currently shows: {value: myData}
// Expected: myData (the actual document from MyCollection)
});
Expected behavior: this.data
should directly contain the document returned by MyCollection.findOne()
.
Actual behavior: this.data
contains {value: myData}
where myData
is wrapped inside a value
property.
Has anyone encountered this issue? What could be causing this extra object wrapper, and how can I get the direct data without the value
wrapper?
Thanks