BigInt type error on CatalogApi

– Console Log

Here is your first location: { id: ‘LZ89B1KRZYV9C’, name: ‘XYZ STORE’, – snip --, mcc: ‘5999’ }

reports::getSearchCatalogItems() Unexpected Error: ReferenceError: BigInt is not defined
at Object.coerceStringOrNumberToBigInt (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/utils.js:68:40)
at Object.map (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/optional.js:20:61)
at Object.map (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/object.js:243:56)
at Object.map (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/lazy.js:19:43)
at /rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/array.js:27:36
at /rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/schema.js:107:20
at Array.map ()
at Object.mapChildren (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/schema.js:106:22)
at Object.map (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/array.js:26:25)
at Object.map (/rbd/pnpm-volume/74a5c72f-8e47-410e-86d2-ac379efb16a5/node_modules/.registry.npmjs.org/@apimatic/schema/0.6.0/node_modules/@apimatic/schema/lib/types/optional.js:20:61)

Code snippet:

  let squareClient = new Client({
    environment: environment,
    accessToken: accessToken,
    squareVersion: null,
    'Content-Type': 'application/json'
  });

  const { locationsApi } = squareClient;
  const { catalogApi } = squareClient;

  const searchCatalogItemsAPIdata = {
      categoryIds: [ "52MKWNKAMWTQZQZVUYII4SDD" ],
      limit: 100,
      cursor: ""
  };

  const items = getSearchCatalogItems(catalogApi, searchCatalogItemsAPIdata);
  const locations = getLocations(locationsApi);

// Create getLocations wrapper async function
const getLocations = async ( olocationsApi ) => {
// The try/catch statement needs to be called from within an asynchronous function
try {
// Call listLocations method to get all locations in this Square account
let listLocationsResponse = await olocationsApi.listLocations()

// Get first location from list
let firstLocation = listLocationsResponse.result.locations[0];

console.log("Here is your first location: ", firstLocation);

return listLocationsResponse.result.locations;

} catch (error) {
if (error instanceof ApiError) {
console.log("reports::getLocations() ApiError: There was an error in your request: ", error.errors)
} else {
console.log("reports::getLocations() Unexpected Error: ", error)
}
}
}

// Create searchCatalogItems wrapper async function
const getSearchCatalogItems = async ( oCatalogItemsApi, searchCatalogItemsAPIdata ) => {
// The try/catch statement needs to be called from within an asynchronous function
try {
let searchCatalogItemsResponse = await oCatalogItemsApi.searchCatalogItems(searchCatalogItemsAPIdata);

// Get first location from list
let firstItem = searchCatalogItemsResponse.result.items[0];

console.log("Here is your first item: ", firstItem);

return searchCatalogItemsResponse.result.items;

} catch (error) {
if (error instanceof ApiError) {
console.log("reports::getSearchCatalogItems() ApiError: There was an error in your request: ", error.errors)
} else {
console.log("reports::getSearchCatalogItems() Unexpected Error: ", error)
}
}
}


getLocations is working as expected, getSearchCatalogItems is failing with the error shown above. I’ve been going in circles on this searchCatalogItems endpoint, please tell me this is an easy fix???

Thank you for any help.

Hi @schrade, I see that you have made several posts but from the looks of your logs you are making progress. Are you still running into issues with SearchCatalogItems?

Hi @Bryan-Square

No, I am completely dead in the water. I ran into the issue in my thrashing around prior to my first post. When I received THIS error initially while ago I thought it was part of being ‘lost’ and went about trying to correct my code, etc. Once I made enough progress to know where the issue is/was (and wasn’t!) I believe it is a larger issue related to Square code/SDK. For THIS issue, I am not able to deserialize the the JSON until someone points me at a work around, or something of that nature. As to the other issue - I’d like some help there as well - a few minutes with one of you guys would likely make a world of difference. Specifically a working example with any part of the category API (implemented in Node.js) and the deserialization of the returned data - I’m trying to build an inventory list for a specific category and then of course retrieve IN_STOCK counts for each of the items. Parsing the CatalogApi response data is no fun for a newbie to the Square APIs.

What can I get you guys in terms of files, etc. so that you can identify/correct the issue?

Thanks in advance for any help/attention you guys can put on these two cries for help!