I'm trying to get app_data because this holds other data that I need, such as quality, but every time I try to log app_data it comes up with undefined, logging itemJson works fine?
Code
function getBPPrice(item, itemJson){
console.log(itemJson);
console.log(itemJson.app_data);
console.log(itemJson.app_data.quality);
console.log(Prices.response.items[item].prices[itemJson.app_data.quality][itemJson.tradable].Craftable[0].value);
}
and
var item = theirItems[i].market_name;
var itemJson = JSON.stringify(theirItems[i], null, 4);
getBPPrice(item, itemJson);
Now, console.log(itemJson); works as I've stated before, but console.log(itemJson.app_data); just outputs undefined, so the next output which is the quality value doesn't work.
Json
Pastebin link because it is quite long, app_data is near the bottom too.
Edit:
Error i get -
undefined C:\Users\datpe\Desktop\d\bot.js:89 console.log(itemJson.app_data.quality); ^
TypeError: Cannot read property 'quality' of undefined at getBPPrice (C:\Users\datpe\Desktop\d\bot.js:89:32) at processOffer (C:\Users\datpe\Desktop\d\bot.js:136:4) at TradeOfferManager.manager.on (C:\Users\datpe\Desktop\d\bot.js:189:2) at emitOne (events.js:115:13) at TradeOfferManager.emit (events.js:210:7) at received.forEach (C:\Users\datpe\node_modules\steam-tradeoffer-manager\lib\polling.js:235:10) at Array.forEach (native) at getOffers (C:\Users\datpe\node_modules\steam-tradeoffer-manager\lib\polling.js:219:12) at Helpers.checkNeededDescriptions (C:\Users\datpe\node_modules\steam-tradeoffer-manager\lib\index.js:483:4) at Async.map (C:\Users\datpe\node_modules\steam-tradeoffer-manager\lib\assets.js:171:4)
JSON.stringify()is a "replacer". If you are simply after "pretty printing" without modification then you wantundefinedthere instead, since that's least likely to actually match anything ( since undefined is not really a JSON output thing ). But you can't access a property from a string, so you seem to have a couple of concepts wrong here.