0
當我從服務器獲得響應時,如何獲取此值?如何在node.js中獲取請求後返回值?
終端在運行時不會輸出任何信息。
console.log(a);
function findMaxID() {
var a = needle.get(URL, function(err, res){
if (err) throw err;
return 222;
});
return a;
}
使用承諾? –
@BelminBedak你能告訴我一個簡單的代碼嗎?我使用promisses很多次,但在這裏,在這個例子中我的承諾不起作用 –
http://stackoverflow.com/questions/22519784/how-do-i-convert-an-existing-callback-api-to優惠可能會有所幫助。 – ste2425