Facing issue while writing rest api endpoint

Topic summary

A developer encountered a TypeError: Cannot read properties of undefined (reading 'User') when attempting to fetch Shopify staff user details via the REST API.

The Issue:

  • Error occurred at line 26 in the shopify-api-node implementation
  • Code was calling Shopify.rest.User.all() instead of using the instantiated object

Root Cause:

  • The Shopify object was instantiated as lowercase shopify but the code referenced uppercase Shopify
  • This case sensitivity mismatch caused the undefined reference

Solution Provided:

  • Use shopify.rest.User.all() (lowercase) to match the instantiated object name
  • Reference provided to the shopify-api-node npm package documentation

Status: Awaiting confirmation from the original poster whether the suggested fix resolved the issue.

Summarized with AI on November 12. AI used: claude-sonnet-4-5-20250929.

‘use strict’;
require(‘dotenv’).config();
const log4js = require(‘log4js’);

const {AppApiKey, AppApiPassword, shopName, SHOPIFY_SHOP_PLAN} = process.env;

const Shopify = require(‘shopify-api-node’);
const shopify = new Shopify({
shopName: shopName,
apiKey: AppApiKey,
password: AppApiPassword
});

/*
Description : Get shopify staff user
@Created_by :Supriya Shirote
@Anonymous null
@Return : shopify staff user details.
*/

const getUserDetails = async (res, req) => {
console.log(‘hi test’);
const sessionToken = shopify;

const staffMembers = await Shopify.rest.User.all({
session: sessionToken,
});
console.log("staffMembers info: "+ JSON.stringify(staffMembers));

}

module.exports = {
getUserDetails
};

But I am getting this error

C:\Audit-info\controllers\shopifyApi.js:26
const staffMembers = await Shopify.rest.User.all({
^

TypeError: Cannot read properties of undefined (reading ‘User’)

As you have assigned the object to shopify, smallcase.
const shopify = new Shopify({

So, you should use it like shopify.user instead of Shopify.user

Please let me know if it worked!
Thanks,
Suyash
Ref: shopify-api-node - npm (npmjs.com)