xLeeJYx Posted July 14, 2017 Report Share 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 Link to comment Share on other sites More sharing options...
Dr. McKay Posted July 14, 2017 Report Share 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 Link to comment Share on other sites More sharing options...
xLeeJYx Posted July 15, 2017 Author Report Share 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 Link to comment Share on other sites More sharing options...
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.