app.get('/playground', handler);
http://localhost:9000/playground
import { useState } from 'react'; | |
// credit: https://usehooks.com/useLocalStorage/ | |
function useLocalStorage(key, initialValue) { | |
const [storedValue, setStoredValue] = useState(() => { | |
try { | |
const item = window.localStorage.getItem(key); | |
return item ? JSON.parse(item) : initialValue; | |
} catch (error) { | |
console.log(error); |
async function asyncForEach(array, callback) { | |
for (let index = 0; index < array.length; index += 1) { | |
// eslint-disable-next-line no-await-in-loop | |
await callback(array[index], index, array); | |
} | |
} | |
// credit to https://codeburst.io/javascript-async-await-with-foreach-b6ba62bbf404 |
{ | |
"type": "ForStatement", | |
"initExpression": { | |
"type": "VariableDeclarationStatement", | |
"variables": [ | |
{ | |
"type": "VariableDeclaration", | |
"typeName": { | |
"type": "ElementaryTypeName", | |
"name": "uint", |
{ | |
"singleQuote": true, | |
"trailingComma": "none" | |
} |
(() => { | |
const script = document.createElement('script'); | |
script.type = 'application/javascript'; | |
script.src = '//s3.amazonaws.com/oc-registry-dc/components/oc-client/0.40.7/src/oc-client.min.js'; | |
script.onload = () => { | |
const html = window.oc.build({ | |
baseUrl: '//oc.registry.dc', | |
name: 'oc-superman', | |
version: '1.0.0', | |
parameters: { |
((oc, $) => { | |
// see: https://github.com/opentable/oc/wiki/Browser-client#ocbuild-options | |
const html = oc.build({ | |
baseUrl: 'http://localhost:3030', | |
name: 'pi-baltimore-special-offers-promo-banners', | |
version: '1.X.X', | |
parameters: { | |
banner: 'purple-pasta' | |
} | |
}); |
/* info: the original "start" from CRA has been renamed to dev and a new "start" that points to server.js has been added */ | |
{ | |
"scripts": { | |
"start": "node server.js", | |
"dev": "react-scripts start", | |
"build": "react-scripts build", | |
"test": "react-scripts test --env=jsdom", | |
"eject": "react-scripts eject" | |
} | |
} |