javascript - Optional parameters in Meteor router -


i have path in meteor

path: '/my-url/:groupid?', 

i have added question mark indicate groupid not used. in data check whether group id set this.params.hasownproperty('groupid') have come across router thinks groupid set if isn't (don't know why) value undefined.

therefore, tried

console.log(this.params.hasownproperty('groupid')); console.log('groupid' in this.params); console.log(this.params.groupid); 

and evaluate to

> true > true > undefined 

so guess hasownproperty not best way check whether groupid set since doesn't check undefined values.

what better way check this? why hasownproperty evaluate true if url /my-url?

i think you've answered on question. have same problem , check is:

if (this.params.groupid) { } else { } 

this not yet confirmed, think long provide :groupid, you're have in params, regardless exists or not.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -