Reputation: 1439
I am working with Meteorjs First time. In my application I am trying to Register a use. For this I am making a meteor call. Which returns me error if it is unsuccessful or success if user is registered successfully. My problem is when Someone try to register a user with a previously registered id meteor call returns error message that user name is already exists.this is my meteor call
var acct = {"email": email, "full_name": full_name, roles: roles}
var id = Meteor.call("register_staff", acct, function (error, result) {
if (error) {
console.log(error)
FlashMessages.sendError(" This email address is already registered")
}
else {
$("#user_creator_dialog").modal('hide');
FlashMessages.sendSuccess("User Successesfully Created and Password Mailed")
}
});
if i do
console.log(error)
Error: Username is already exists.
But when I try to get the key by using dot(.) notation like
console.log(error.Error)
Upvotes: 0
Views: 1044
Reputation: 4639
If your Meteor method is throwing a new Meteor.Error the keys will include error, errorType, message, reason, and details. "Error" is the object but not one of the keys so "error.Error" in your callback will return undefined.
Try error.reason or error.message and see if that does it. It depends what is being returned from the method.
Upvotes: 1