Hi people trying to compile this web request here: http://csgobackpack.net/api/GetItemsList/v2/?no_details . Here is the js code I am using
updateMarketPrices();
function updateMarketPrices() {
request('http://csgobackpack.net/api/GetItemsList/v2/?no_details', function(error, response, body) {
prices = JSON.parse(body);
prices['migration_time_validation'] = JSON.stringify(database_params);
if(prices.response.success == true) {
logger.warn('Loaded fresh prices');
if(fs.existsSync('/var/www/prices.txt')){
prices = JSON.parse(fs.readFileSync('/var/www/prices.txt'));
logger.warn('Prices loaded from cache');
} else {
logger.error('No prices in cache');
process.exit(0);
}
} else {
fs.writeFileSync('/var/www/prices.txt', body);
logger.trace('New prices loaded');
}
});
}
using these npm packages:
var request = require('request');
var fs = require('fs');
The return I am getting is:
if(prices.response.success == true) {
^
TypeError: Cannot read property 'success' of undefined
at Request._callback (/home/bot/prices.js:52:22)
at Request.self.callback (/home/bot/node_modules/request/request.js:185:22)
at Request.emit (events.js:314:20)
at Request.<anonymous> (/home/bot/node_modules/request/request.js:1154:10)
at Request.emit (events.js:314:20)
at IncomingMessage.<anonymous> (/home/bot/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:420:28)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
What could you suggest thanks people...
Aucun commentaire:
Enregistrer un commentaire