I've changed the structure slightly as I don't think the requests were chaining properly, i.e all being sent after the setTimeout delay, so it now uses an async promise chaining structure to repeat the request n amount of times (I plan to iterate over the size of marketItemsObject.length, but testing with just 3 requests for now). I've also changed the timeout delay to between 10 and 20 seconds, however it still seems only to be only returning the first item, and either failing or not attempting the rest. As you may say this probably might be rate limiting however so i'm going to leave it until tomorrow to see if there is any sort of reset on the limit, with a much larger interval. Here's the re-done code for reference
getMarketFunctionIsHere().then(function (marketItemsObject) {
async function asyncRepeat(f, n) {
var i = 0;
while (n-- > 0)
i += await f(i);
}
function itemFunction(i) {
return new Promise(function (resolve, reject) {
setTimeout(() => {
console.log('i is currently: %d', i);
console.log(marketItemsObject[i].price_gbp);
csgo.inspectItem(marketItemsObject[i].id, marketItemsObject[i].assetID, marketItemsObject[i].d, () => {
console.log("Sent an inspect item request");
});
resolve(1); // resolve 1 to be added to index
}, 50000);
});
}
asyncRepeat(itemFunction, 3).then(() => {
console.log("Completed Inspections");
});
});