– 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.