Hi there,
I’m trying to make a chrome browser extension that uses Square’s Inventory API to pull our store’s physical inventory count and displays it in a box on our distributor’s website. However, I’m having trouble understanding how to get only one piece of information (the catalog ID) when searching catalog items.
I don’t really have much programming knowledge, but this is what I have so far:
function get_itemid() {
try {
const response = await client.catalogApi.searchCatalogItems({
textFilter: '[SKU goes here]',
limit: 100,
console.log(response.result);
} catch(error) {
console.log(error);
}
}
function get_stocklevel() {
try {
const response = await
client.inventoryApi.retrieveInventoryCount(' [HOW DO I PUT THE CATALOG ID FROM ABOVE HERE?] ');
}
}
There’s more code for injecting the stock level locally into the other website, but I think I have that down. The main thing I’m missing is how to pull info from one piece of code/function into another. I’m guessing it’s via a ‘var’, but the get_itemid function pulls a lot of extraneous info when all I need is the item ID for the get_stocklevel function.
Thanks in advance!