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 trialPattey Bleecker
Full Stack JavaScript Techdegree Graduate 18,770 PointsLogin 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
3 Answers
Jack Blankenship
Full Stack JavaScript Techdegree Graduate 39,036 Pointsthe generateOrFindUser function has a typo. The code should read
{ email: profile.emails[0].value },
Isaac Henry
15,541 Pointswhy do you hava a zero in the email erray
Jack Blankenship
Full Stack JavaScript Techdegree Graduate 39,036 Pointsto 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) {
Isaac Henry
15,541 PointsIsaac Henry
15,541 Pointswell what did you try,And you dont have too do the example in the video somtimes you can do it an easyer way