Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Facebook Authentication

Pattey Bleecker
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Pattey Bleecker
Full Stack JavaScript Techdegree Graduate 18,770 Points

Login error with both github and facebook

I've completed ethe OAuth workshop, but get this error when running the final code:

Cast to string failed for value "{ value: 'pattey.bleecker@gmail.com' }" at path "email" for model "User"

Any one know what the problem is

well what did you try,And you dont have too do the example in the video somtimes you can do it an easyer way

3 Answers

why do you hava a zero in the email erray

Jack Blankenship
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jack Blankenship
Full Stack JavaScript Techdegree Graduate 39,036 Points

to grab the first entry's value and store it in the user table. I also had to change code because github does not even return the email property if that does not have a value.

    let propertyArray = Object.getOwnPropertyNames(profile);
    // the following if fails if the email property is not passed.
    //if(profile.emails[0]) {
    if  (propertyArray.indexOf('emails') >= 0) {