异步,异步,异步。
您不能从该函数返回异步操作的结果。该函数早已在调用异步回调之前返回。因此,唯一消耗您结果的地方
request.post()是在回调本身内部,并通过从该回调内部调用其他函数并将数据传递给该其他函数来进行。
var oauth = request.post(oauthOptions, function(e, r, body) { // use the result here // you cannot return it // the function has already returned and this callback is being called // by the networking infrastructure, not by your pre // you can call your own function here and pass it the async result // or just insert the pre here that processes the result processAuth(body);});// this line of pre here is executed BEFORE the callback above is called// so, you cannot use the async result here仅供参考,对于新的node.js / Javascript开发人员来说,这是一个非常常见的学习问题。要在节点中进行编码,您必须学习如何使用这样的异步回调。



