I'm following a tutorial on learning MeteorJS, however I get this strange error when calling the 'Accounts' object method 'createUser':
Meteor: Uncaught ReferenceError: Accounts is not defined
I looked up the docs, and Meteor offers a whole account system on installing Meteor in your project. (https://www.meteor.com/accounts). What is the cause of this error? I can't find an answer to this.
My code:
if (Meteor.isClient) {
Template.login.creatingAccount = function()
{
return Session.get('creatingAccount');
},
Template.login.events({
'click #loginform': function()
{
Session.set('creatingAccount', false);
},
'click #accountform': function()
{
Session.set('creatingAccount', true);
},
'click #createAccount': function(e,t)
{
//make sure to show the login form
Session.set('creatingAccount', false);
Accounts.createUser({
username: t.find('#username').value,
password: t.find('#password').value,
email: t.find('#email').value,
profile: {
name: t.find("#username").value,
email: t.find("#email").value
}
});
},
});
}
It's likely that one of the accounts packages was not added to your project. Try:
$ meteor add accounts-password
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