【发布时间】:2014-03-31 11:45:55
【问题描述】:
这是我的代码,
googleContacts:function()
{
var opts= { email: Meteor.user().services.google.email,
consumerKey: "xxxxxxxx",
consumerSecret: "xxxxxxxxxx",
token: Meteor.user().services.google.accessToken,
refreshToken: Meteor.user().services.google.refreshToken};
gcontacts = new GoogleContacts(opts);
gcontacts.refreshAccessToken(opts.refreshToken, function (err, accessToken)
{
if(err)
{
console.log ('gcontact.refreshToken, ', err);
return false;
}
else
{
console.log ('gcontact.access token success!');
gcontacts.token = accessToken;
gcontacts.getContacts(function(err, contact)
{
console.log(contact);
return contact;//want to return this value
})
}
});
}
我想将contact返回给被调用的方法,因为它在一个内部函数中,我有点难以将它返回给被调用的方法。如果它在客户端,那么我们可以存储会话变量中的值,我们可以返回它,但这是一个服务器端方法,如何做到这一点?
【问题讨论】:
-
参见“如何使用异步...”部分here。
-
是的,试过了,但我没有正确,谁能告诉我怎么做?