Session.get does return object object

Hi,

I am trying a simple set and get session, but the problem is that is does not return a string.

Template.bestelling.events({ 'click .title': function(ev){ var selectedCategory = this; console.log('category clicked: '+selectedCategory); Session.set('selectedCategory', selectedCategory); console.log('na setten is de get: '+Session.get('selectedCategory'); },

returns

category clicked: Gourmet / Fondue / Steengrill
na setten is de get: [object Object]

If you’re getting selectedCategory through this, it’s actually a wrapped String object. I’d suggest doing:

var selectedCategory = this.valueOf();

Which will unwrap the object.

1 Like

Thank you, this worked!

can I give you points or something to thank you?