Auth0 Home Blog Docs

Cannot read property 'picture' of undefined



I’m trying to access the profile picture of a user and display it. I’m using the Angular2-CLI Login-01 example, and I get the error in the subject heading. Here is my HTML:

<img [src]="profile.picture" class="profile-avatar"/>

I also tried a simple user_metadata attribute like:

<h4>Welcome, {{ profile.first_name }}</h4>

…and I get a similar error, "cannot read property of ‘first_name’ of undefined. My AngularJS Auth0 app worked without a hitch when displaying user_metadata, so I need advice here.


I’ve gotten the user pic to show up with:

<img src="{{profile?.picture}}" class="profile-avatar-lg">

but when I try to access the user_metadata with:

{{ profile?.user_metadata.first_name }}

I get the error ERROR TypeError: Cannot read property 'first_name' of undefined