Error when calling Storefront API - "Cannot read property 'Storefront' of undefined"

mmk9
Visitor
2 0 0

I've been following the GraphQL Storefront API documentation and attempting to use the Node.js code example found under the Endpoints and queries section of this page - https://shopify.dev/api/storefront#endpoints


The error that I get is "TypeError: Cannot read property 'Storefront' of undefined", which is occurring on the following section of the example code.

 
const storefrontClient = new Shopify.Clients.Storefront(
shop,
storefrontAccessToken,
);
 

I'm not sure why the Storefront property is absent from the Shopify object. It looks like the Clients property itself is also absent. When I examine the Shopify object through logging, I notice that Session, Clients and Context properties are all undefined. Alternatively, the ApiVersion and default properties are present and contain data. Also, if I change the problematic code from Shopify.Clients.Storefront to Shopify.default.Clients.Storefront, the code will run without error. Though I don't think that's the correct solution.

 

Could anyone point me in the right direction for why some of these properties aren't accessible on the Shopify object, while others are? It seems like accessing the Clients property should be simple, but maybe I'm somehow using an incorrect version. Thank you very much for the help.

Replies 0 (0)