[英]How can I Get birthday from OAuth facebook nodejs? (I can log it in the terminal but can't access it)
當我做 console.log(profile) 我得到一切,當我做 console.log(profile.name) 我得到我的名字但是當我做 console.log(profile.birthday) 我什么都沒有...
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['email', 'user_birthday'] }));
我在終端中得到以下輸出:
_json: {
id: '10216001524809335',
name: 'Rani Verelst',
last_name: 'Verelst',
first_name: 'Rani',
birthday: '05/26/1996',
picture: { data: [Object] },
email: 'verelst.rani@gmail.com'
}
}
如何使用生日數據在我的路由器中存儲和使用?
可以通過對象中的 ._json 訪問返回的配置文件數據,因此請執行以下操作以通過解構獲取所有屬性,包括您提到的生日
const { first_name, last_name, birthday } = profile._json;
您可以將其余屬性添加到解構中。 如果你不想解構,那么直接訪問
const birthday = profile._json.birthday;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.