添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
开朗的小刀  ·  Logi Options+ ...·  7 月前    · 
年轻有为的鸵鸟  ·  Getty Images·  8 月前    · 
飘逸的登山鞋  ·  python 并发请求grpc ...·  10 月前    · 
Hello! I am currently working on a project where I would like users to be able to connect via google and save their data in my database (MongoDB). the redirection works perfectly but when I connect with my account I get an error like:
Cannot read property '0' of undefined.
What I have tried:
file: google.strategy.ts
TypeScript
public async validate(accessToken: string, refreshToken:string, profile: any, done: VerifyCallback): Promise<User> { // const { name, emails, photos } = profile // const user = { // email: emails[0].value, // firstName: name.givenName, // lastName: name.familyName, // picture: photos[0].value, // accessToken // done(null, user); const newUser = new this .UserModel(); newUser.userId = uuidv4(); newUser.accessToken = accessToken; newUser.name = profile.name.giveName + ' ' + profile.name.familyName; newUser.email = profile.emails[ 0 ].value; newUser.phone = profile.phone[ 0 ].value; newUser.picture = profile.photos[ 0 ].value; // done(null, newUser); return newUser.save();
TypeScript
public async validate(accessToken: string, refreshToken:string, profile: any, done: VerifyCallback): Promise<any> { const newUser = new this .UserModel(); newUser.userId = uuidv4(); newUser.accessToken = accessToken; newUser.name = profile.name.givenName + ' ' + profile.name.familyName; newUser.email = profile.emails[ 0 ].value; newUser.picture = profile.photos[ 0 ].value; return newUser.save( function (err) { if (err) throw err; return done( null , newUser);
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •