Skip to content

Instantly share code, notes, and snippets.

@petercossey
Last active September 8, 2022 21:26
Show Gist options
  • Save petercossey/e57e05a084f31c21bab3953fd107cd3d to your computer and use it in GitHub Desktop.
Save petercossey/e57e05a084f31c21bab3953fd107cd3d to your computer and use it in GitHub Desktop.
Javascript snippet for loading a cart in a BigCommerce Stencil environment
const storefrontCartUrl = "https://peters-everything-store.mybigcommerce.com/api/storefront/carts"
const getCart = async (url) => {
try {
const response = await fetch(url, {
"method": "GET",
"headers": {
"Content-Type": "application/json"
}});
const json = await response.json();
return json;
} catch (err) {
console.log(err);
}
}
const cart = await getCart(storefrontCartUrl)
console.log(cart)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment