Skip to content

Instantly share code, notes, and snippets.

View levimichael's full-sized avatar

Levi Whalen levimichael

View GitHub Profile
@levimichael
levimichael / checkout.js
Created July 20, 2021 18:10
Nacelle Nuxt Starter Checkout Vuex Store
import { get, set } from 'idb-keyval'
const isFunc = (func) => typeof func === 'function'
function handleCheckoutError(err) {
if (err.message && err.message.startsWith('401')) {
console.warn(
'Received a 401 (unauthorized) response when attempting checkout. ' +
'Please verify your Checkout Settings in the Nacelle Dashboard. ' +
'Most likely, the token is incorrect, or there is a typo in the endpoint URL.'
)
@levimichael
levimichael / cart.js
Last active July 20, 2021 18:11
Nacelle Starter Cart Vuex Store
import { get, set, del } from 'idb-keyval'
import { v4 as uuid } from 'uuid'
export const state = () => ({
lineItems: [],
cartVisible: false,
freeShippingThreshold: null,
error: null
})
export const getters = {
@levimichael
levimichael / .js
Created February 8, 2021 23:47
Worker Delayed Scripts
const loadGTag = () => {
if (typeof window !== "undefined") {
const rootScript = document.getElementsByTagName("script")[0]
const gtagScript = document.createElement("script")
gtagScript.type = "text/javascript"
gtagScript.defer = true
gtagScript.src =
"https://www.googletagmanager.com/gtag/js?id=<ID HERE>"
rootScript.parentNode.insertBefore(gtagScript, rootScript)
@levimichael
levimichael / BackInStock.vue
Created March 30, 2020 16:49
Back In Stock Notification Component
<template>
<div>
<input type="email" v-model="emailAddress" placeholder="Enter your email..." @keydown.enter="sendBackInStockNotificationRequest"/>
<button @click="sendBackInStockNotificationRequest">Send</button>
</div>
</template>
<script>
import axios from 'axios'
export default {

Keybase proof

I hereby claim:

  • I am levimichael on github.
  • I am leviwhalen (https://keybase.io/leviwhalen) on keybase.
  • I have a public key ASDw4WeU8i0qxyoz9nkcbKbOR034sTTYv8Ot3HuVFOPF9Qo

To claim this, I am signing this object: