Where to find appId for createCart?

I have just started working on current cart. Below is the basic backend code I’ve written for adding a product to currentCart.

export async function addToCurrentCart(options) {
    try {
        const updatedcart = await currentCart.addToCurrentCart(options);
        console.log("updated cart - ", updatedcart);
        return updatedcart;
    } catch (error) {
        console.log(error);
    }
}

And this is the front-end code i’ve written for when the user clicks on add to cart.

export function productAddToBag_click(event) {
    const options = {
        lineItems: [{
            catalogReference: {
                appId: appId,
                catalogItemId: currentItem._id,
                options: {
                    variantId: currentItem.sku
                }
            },
            quantity: 1
        }]
    }
    addToCurrentCart(options)
    .then((updatedCart) => {
        console.log(updatedCart);
        const cartId = updatedCart._id;
        const numberOfCartLineItems = updatedCart.lineItems.length;
        console.log("updated cart - ", cartId, numberOfCartLineItems);
    })
    .catch((error) => {
        console.log(error);
    })
}

when i run this code, I get error in Logs console in dashboard.

"root":{

"insertId":"..........5YVP7CHZ_6QObm638OgKDI"
"timestamp":"2023-02-08T20:27:04.423Z"

"labels":{"siteUrl":"n/a"
"revision":"1102"
"namespace":"Velo"
"tenantId":"31c27d41-00ca-4a3d-8f8f-2184e503131c"
"viewMode":"Site"
}

"sourceLocation":{"file":"backend/cart.jsw"
"line":21
"column":16
}

"operation":{"id":"1675888021.73335377735126223"
"producer":"backend"
}

"jsonPayload":{"message":"["message: 'INVALID_ARGUMENT: \"options.lineItems[0].catalogReference.appId\" has size 0, expected 1 or more'\ndetails:\n validationError:\n fieldViolations:\n - field: options.lineItems[0].catalogReference.appId\n description: has size 0, expected 1 or more\n violatedRule: MIN_LENGTH\n data:\n threshold: 1"]"
}
"receiveTimestamp":"2023-02-08T20:27:04.926Z"
}

It says invalid argument and pretty obvious that there’s a problem with appId. Can someone guide me? What to provide in appId?

The catalog reference requires the private appId of your published site catalog. Each catalog you create on the site will have a unique app ID that must be referenced in your code so that it is understood which catalog you are targeting.

Currently there is a workaround to get this value that will be improved in the future.

You will need have your logs open to retrieve the value which you will then need to add to your catalog reference (currently you are not passing anything in hence the 0)

Steps:

  1. Check that your catalog was successfully added as an app by goign to manage apps in your dashboard.

  2. Next open your logs. > open site events

  3. Click publish with your site events open and you will see a new INFO line in the logs showing the ecomm catalog integration

  4. Expand this to find your appID value (it will be in the JSON payload message) and place it in the code.

See also steps 9-11 in the tutorial for context: https://support.wix.com/en/article/velo-tutorial-ecommerce-catalog-custom-extension-beta

Let me know if this resolves your issue