Skip to content

Instantly share code, notes, and snippets.

View MamacitaStyle's full-sized avatar
🥴
Trabajando desde casa

MamacitaStyle

🥴
Trabajando desde casa
View GitHub Profile
@andria-dev
andria-dev / front-end.jsx
Created February 16, 2021 03:57
Example usage of use-shopping-cart for README
// Front-End: Let's pick our product, ask for a Session ID, and redirect to the checkout page.
import { useShoppingCart, formatCurrencyString } 'use-shopping-cart'
function Product({ product }) {
const { redirectToCheckout } = useShoppingCart()
const { name, image, description, currency } = product
const price = formatCurrencyString({ value: product.price, currency, language: 'en-US' })
async function buyNow() {
const response = await fetch("/.netlify/functions/create-session", {