Using the node.js framework Meteor -
how come the currentUser
variable is defined in a template such as here:
<template name="main_template">
<div class="container">
{{#if currentUser}}
{{> add_player_form_template}}
{{/if}}
</div>
</template>
but when I call currentUser
from the console, it's undefined:
however, Meteor.userId
is defined:
why is this?
userId() import { Meteor } from 'meteor/meteor' (accounts-base/accounts_common.js, line 410) Get the current user id, or null if no user is logged in.
Meteor is a full-stack JavaScript platform for developing modern web and mobile applications. Meteor includes a key set of technologies for building connected-client reactive applications, a build tool, and a curated set of packages from the Node. js and general JavaScript community.
`accounts-base` This package is the core of Meteor's developer-facing user accounts functionality.
{{ currentUser}}
is a helper in the main_template
template.
In your client Javascript you'll need to define that helper method. Something like:
Template.main_template.helpers({
currentUser: function() {
return Meteor.userId();
}
})
This may help too http://docs.meteor.com/#/basic/templates.
{{ currentUser }}
is a template helper that simply calls Meteor.user()
.
In the console, you need to call Meteor.user()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With