【发布时间】:2017-03-31 19:51:18
【问题描述】:
如何在回调之外访问变量库存? 我想访问它并返回它。
loadInventory = function () {
var inventory = [];
offers.loadMyInventory({
appId: 730,
contextId: 2,
tradableOnly: true
}, function (err, items) {
items.forEach(function (item) {
inventory.push({
asset_id: item.id,
market_name: item.market_name
});
});
//Not accessible here
});
};
【问题讨论】:
-
//这里不可访问是在上面的回调中,
-
你能分享工作代码以便我执行它吗?
标签: javascript node.js variables scope callback