function getSenderName(senderId) {
var __name;
// Get user's first name from the User Profile API
// and include it in the greeting
request({
url: "https://graph.facebook.com/v2.6/" + senderId,
qs: {
access_token: process.env.PAGE_ACCESS_TOKEN,
fields: "first_name"
},
method: "GET"
}, function(error, response, body) {
if (error) {
console.log("Error getting user's name: " + error);
} else {
var bodyObj = JSON.parse(body);
__name = bodyObj.first_name;
console.log("1.SenderId : " + senderId + " Name : " + __name);
}
});
console.log("2.SenderId : " + senderId + " Name : " + __name);
return __name;
}
上面的代码我得到了
1.SenderId : 1234 Name : Vinay
2.SenderId : 1234 Name : Undefined
任何人都可以帮助我如何访问这种嵌套函数内的变量
答案 0 :(得分:1)
只是为了让你知道,
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_GTK=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DWITH_QT=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
回调可以完成相同的工作..