我想在咖啡脚本中设置并获取对象的值。我的代码看起来像
global.fbUserData = ''
unless fbUserData
#Use facebook strategy
passport.use new FacebookStrategy(
clientID: 'XXXXXX'
clientSecret: 'XXXXXX'
callbackURL: 'http://localhost:com/auth/facebook/callback'
, (accessToken, refreshToken, profile, done) ->
fbUserData.name = profile.displayName
fbUserData.email = profile.emails[0].value
done null, profile
)
当在Facebook回调路线中我想访问global fbUserData
对象时,它返回我未定义的
app.get "/auth/facebook/callback", passport.authenticate("facebook",
failureRedirect: "/user"
), (req, res) ->
res.send "User Name " + fbUserData.name + " User Email " + fbUserData.email
此处fbUserData.name
和fbUserData.email
未定义。如何设置变量值并在同一页面上获取所需的值?