I have a very basic question but I couldn't find any similar questions. I have the following code:
var admin_li = helper.h('li', [fpu_link('/admin', 'control', false)]);
if (Discourse.User.current().admin) {
menu_li.push(admin_li);
}
I get the following error in the DevTools:
Uncaught TypeError: Cannot read property 'admin' of null
How can I check if the Discourse.User.current()
has a property/method of admin
in the if
statement?