Jump to content


How to get Express to show backpack in nodejs

  • Please log in to reply
No replies to this topic

#1 Lonster_Monster



  • Member
  • PipPip
  • 25 posts

Posted 03 December 2018 - 11:48 PM

I am working on a site and want to get steam items with nodejsand express i understand how to get item inventory and i am using the get-steam-inventory npmmodule and not sure on why the backpack is not being generated in the express below is the price.js file i have for price.pug and in the pug file i call each item in items and cannot get the value of length any help would be appreciated

var express = require('express');

var router = express.Router();
//var pages = require('../pages/Pages.json');
//var quality = require('../public/730/quality.json')
var fs = require('fs');
var data;
var steamid;
var backpack;
var appid = 440;
const steaminventory = require('get-steam-inventory');

/* GET users listing. */
router.get('/', function(req, res, next) {
    // render template
	steamid = req.user.steamid
	var path = './public/json/'+steamid+'.json';
    res.render('price', {user: req.user, items: req.backpack});
function checkFile(path) {
	try {
		if (fs.statSync(path)) {
			fs.readFile(path,"utf8", (err, backpack) => {
			  if (err) throw err;
			backpack = backpack
	} catch(err) {
		steaminventory.getinventory(appid, steamid, function(err, items){
		  if(err) {
			return console.log("Error, while getting user items. Please check settings or user inventory is hidden.");
		  } else {
			if (items){
				fs.writeFile(path, JSON.stringify(items.raw, null, 4), { flag: 'w' }, function (err) {
					if (err) throw err;
					console.log('\x1b[32m','The file has been saved!','\x1b[0m');


module.exports = router;

Also tagged with one or more of these keywords: Question

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users