Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Retrieving an empty products array with JS-Buy-SDK

Shopify Partner
3 0 0

I have 20 products and also created a collection filled with products. When I fetch theses products like you see below I get an empty array back... 

import Client from 'shopify-buy';

const storeDomain: string = process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN ?? ''
const accessToken: string = process.env.NEXT_PUBLIC_SHOPIFY_STORE_FRONT_ACCESS_TOKEN ?? ''

// Initializing a client to return content in the store's primary language
const shopifyClient = Client.buildClient({
    domain: storeDomain,
    storefrontAccessToken: accessToken,

const parseShopifyResponse = (response: any) => JSON.parse(JSON.stringify(response));

export { shopifyClient, parseShopifyResponse };


import type { NextPage } from 'next';
import Layout from 'src/components/Layout';
import { shopifyClient as client, parseShopifyResponse } from 'src/shopify/initialize-js-buy-sdk';

const Home: NextPage = () => {

    const resp = async () => {
        const products = await client.product.fetchAll(10);

        console.log('products', products);
        const resp = parseShopifyResponse(products);

        console.log('resp', resp);

        const collectionsData = await client.collection.fetchAllWithProducts();

        console.log('collectionData', collectionsData);
        const collections = parseShopifyResponse(collectionsData);

        console.log('collections', collections);


    return (

export default Home;


Reply 1 (1)

Shopify Partner
3 0 0

Found the answer.. Had to check available channels in the under products.