Skip to content

Instantly share code, notes, and snippets.

@jmwind
Last active September 23, 2020 15:05
Show Gist options
  • Save jmwind/e34f2ee5e7c39b9ef7e9e9c65e43f241 to your computer and use it in GitHub Desktop.
Save jmwind/e34f2ee5e7c39b9ef7e9e9c65e43f241 to your computer and use it in GitHub Desktop.
const jsonQ = require('jsonq');
const fetch = require('node-fetch');
const open = require('open');
const shop_url = 'https://sc-bushfire-appeal.com';
const generosity_level = 5;
function extractAllVariants(data) {
const json = jsonQ(data);
const products = json.find('products');
const variants = products.find('variants').find('id');
let variant_url = "";
variants.value().forEach(id => {
variant_url += `${id}:${generosity_level},`
});
const cart = `${shop_url}/cart/${variant_url}`;
open(cart);
}
fetch(`${shop_url}/products.json`)
.then(response => response.json())
.then(data => extractAllVariants(data))
@xssc
Copy link

xssc commented Sep 22, 2020

Nice touch on switching to template strings!

@cool
Copy link

cool commented Sep 22, 2020

will people think im funny if i reply to jmwind github post too

nah

@alii
Copy link

alii commented Sep 22, 2020

will people think im funny if i reply to jmwind github post too

nah

ego

@g-delmo
Copy link

g-delmo commented Sep 22, 2020

Interesting use of snake case

@slagathor2094
Copy link

y'all code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment