Guest Ino Posted September 1, 2017 Report Share Posted September 1, 2017 (edited) Hello , I try to get the price of each item, but I do not have time to do it, and I return the undefined . How i can get price of each items ?My code---resolve it with promiseclose theme please Edited September 1, 2017 by Ino Quote Link to comment Share on other sites More sharing options...
flyingscot5 Posted October 7, 2017 Report Share Posted October 7, 2017 Hello , I try to get the price of each item, but I do not have time to do it, and I return the undefined . How i can get price of each items ?My code---resolve it with promiseclose theme please would you mind how you managed to solve the problem. Quote Link to comment Share on other sites More sharing options...
xLeeJYx Posted October 8, 2017 Report Share Posted October 8, 2017 would you mind how you managed to solve the problem.he already said using promises. Youve gotta learn how to use promises for async functions Quote Link to comment Share on other sites More sharing options...
Axle Posted October 8, 2017 Report Share Posted October 8, 2017 would you mind how you managed to solve the problem.The async nodeJS module is also a good alternative if you don't want to use promises. They're basically the same thing except it makes code a lot neater. Quote Link to comment Share on other sites More sharing options...
flyingscot5 Posted October 10, 2017 Report Share Posted October 10, 2017 he already said using promises. Youve gotta learn how to use promises for async functionsThe Promise is the easy part that's not what I was getting at. The issue I have is I can't slow it down for rate limit so I'm wondering how he managed that. Quote Link to comment Share on other sites More sharing options...
Guest Ino Posted October 25, 2017 Report Share Posted October 25, 2017 (edited) The Promise is the easy part that's not what I was getting at. The issue I have is I can't slow it down for rate limit so I'm wondering how he managed that. community.getUserInventory(steamid, 730, 2, true, function(err, inventory) { if( inventory !== undefined ) { let items = inventory.map( (item, idx) => { return new Promise((resolve, reject) => { community.getMarketItem(730, item.market_name, function(err, items) { if (err) { console.log(err); resolve([]) } else { resolve(items.lowestPrice) } }); }).then( price => { return { name: item.market_name, assetsId: item.assetid, iconUrl: (item.icon_url_large == undefined) ? item.icon_url : item.icon_url_large, price: price / 100 } }) }) Promise.all(items).then( result => { // Do this something }) } Edited October 25, 2017 by Ino Quote Link to comment Share on other sites More sharing options...
flyingscot5 Posted November 27, 2017 Report Share Posted November 27, 2017 I still don't think that's going to work because of steam itself as steam returns 403 after the first 5 items. 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.