xLeeJYx Posted July 14, 2017 Report Posted July 14, 2017 With this code below i got [ ] in console. Not sure what i done wrong function priceCheckCard(item) { var cardPrices = []; market.getItemPrice(item.appid, item.market_hash_name, (err, data) => { if (err) { console.log(err.message) } else { cardPrices.push(data.median_price) } }) return cardPrices } Quote
Dr. McKay Posted July 14, 2017 Report Posted July 14, 2017 You're pushing the data correctly, you just seem to not understand async. Calling market.getItemPrice is essentially requesting that it retrieve the item price and then let you know when it's finished. You then return immediately, without waiting for the callback. Quote
xLeeJYx Posted July 15, 2017 Author Report Posted July 15, 2017 You're pushing the data correctly, you just seem to not understand async. Calling market.getItemPrice is essentially requesting that it retrieve the item price and then let you know when it's finished. You then return immediately, without waiting for the callback.i really cant understand a single thing about async ._. i looked through the google and youtube but still cant understand Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.