Jump to content
McKay Development

Wait For Items Price (community.getMarketItem)


Guest Ino

Recommended Posts

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 promise

close theme please 

Edited by Ino
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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 by Ino
Link to comment
Share on other sites

  • 1 month later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...