UNPKG

@nacelle/compatibility-connector

Version:

Connect @nacelle/client-js-sdk to Nacelle's v2 back end with minimal code changes

14 lines (12 loc) 662 B
import type { StorefrontInstance } from 'storefrontSdkV1'; import type { StorefrontInstanceV2 } from '../connector/index'; export function checkStorefrontSdkMethod( client: StorefrontInstance | StorefrontInstanceV2, methodName: 'content' | 'navigation' | 'products' | 'spaceProperties' ): void { if (typeof (client as StorefrontInstance)[methodName] === 'undefined') { throw new Error( `The provided 'params.client' does not have a '${methodName}' method. If using @nacelle/storefront-sdk@2.x major version 2, be sure to initialize the client with the Commerce Queries plugin before passing it to @nacelle/compatibility-connector.` ); } }