Hi, I’m trying to following your documentation for the JavaScript Buy SDK (here) but I’m not able to get all products.
My code is
<script src="http://sdks.shopifycdn.com/js-buy-sdk/v2/latest/index.umd.min.js"></script>
<script>
// Initialize the client
var client = ShopifyBuy.buildClient({
domain: 'perroslife.myshopify.com',
storefrontAccessToken: 'shpat_xxxxxxxxxxxxxxxxxxxxxxe01c'
});
console.log(client); // I get a response
client.product.fetchAll().then((products) => {
console.log(products); // I get errors
});
</script>
Hi, thanks for help.Sorry I’m a bit confused… If I use the above token with PHP or curl, I get the products as expected. Instead with Js Buy SDK I can’t make it work. That’s why I think the token is correct. Shall I leave the JS Buy SDK and use curl instead?
If it’s for a single shop you can create a private app, when doing so the very bottom of the private app page you’ll see a “Storefront API” section. The token provided there is what you need for the JS Buy SDK. The Buy SDK is just a wrapper around the Storefront API.
I’ve attached an image as a reference for the token you need.