Last active
September 8, 2022 21:26
-
-
Save petercossey/e57e05a084f31c21bab3953fd107cd3d to your computer and use it in GitHub Desktop.
Javascript snippet for loading a cart in a BigCommerce Stencil environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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