Skip to content

Instantly share code, notes, and snippets.

@procarrera
Created August 19, 2022 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save procarrera/114781de59c97d4e9576a0ce1bfc91ad to your computer and use it in GitHub Desktop.
Save procarrera/114781de59c97d4e9576a0ce1bfc91ad to your computer and use it in GitHub Desktop.
Shopify Get Product JSON by ID
const fetchProductJSON = async (product_id) => {
const id = parseInt(product_id)
const since_id = id - 1
try {
const baseURL =
"https://powerkitchen.ca/products.json?since_id=" + since_id;
const res = await fetch(baseURL);
const data = await res.json();
const product = data.products.filter(p=>p.id == id)[0]
return product;
} catch (e) {
console.error(e);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment