为什么推动库存不起作用?当我记录库存时,所有内容都打印在[]。
中var request = require('request'),
stockJSON = 'https://www.supremenewyork.com/mobile_stock.json?c=1';
var inventory = [];
request({
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'
},
uri: stockJSON
}, function(err, resp, body) {
var json = JSON.parse(body);
inventory.push(json.products_and_categories.new);
});
console.log(inventory);