Skip to content
Advertisement

Access user email address in Meteor JS app

I am building an app using Meteor and need to access the stored email address of a logged-in user.

I am currently using:

JavaScript

to access the user. However, I am only able to access the id. The email address is stored in a nested object that looks like this:

JavaScript

I have tried various ways to traverse the JSON object but can’t figure out how to access the value I need.

Advertisement

Answer

Meteor.user().emails[0].address works for me.

Here’s what the doc says:

By default the server publishes username, emails, and profile. See Meteor.users for more on the fields used in user documents.

Example user document:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement