Advanced Options in Meteor Router
I have a way to Meteor
path: '/my-url/:groupId?',
I added a question mark to indicate that it is sometimes groupId
not used. In data
I check if the this.params.hasOwnProperty('groupId')
groupId is set using , but I ran into the fact that sometimes the router thinks the groupId is set even if it is not (not sure why) but the value undefined
.
So I tried
console.log(this.params.hasOwnProperty('groupId'));
console.log('groupId' in this.params);
console.log(this.params.groupId);
and they value the value
> true
> true
> undefined
So, I guess hasOwnProperty
not the best way to check if set groupId
as it does not check for undefined values.
What would be the best way to test this? Why hasOwnProperty
evaluates to true even though my url is /my-url
?
source to share