diff --git a/.env.sample b/.env.sample index e68f244..2d36713 100644 --- a/.env.sample +++ b/.env.sample @@ -1 +1,2 @@ -M2_CONFIG_HOST=https://www.your-magento-site.com \ No newline at end of file +M2_CONFIG_HOST=https://www.your-magento-site.com +M2_CONFIG_STORE=default diff --git a/src/config.ts b/src/config.ts index 3ad1f45..e47f78d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,2 +1,3 @@ export const host = process.env.M2_CONFIG_HOST; export const graphQlHost = `${host}/graphql`; +export const store = process.env.M2_CONFIG_STORE; \ No newline at end of file diff --git a/src/fetchWithGraphQl.ts b/src/fetchWithGraphQl.ts index 711d996..e1f92cf 100644 --- a/src/fetchWithGraphQl.ts +++ b/src/fetchWithGraphQl.ts @@ -1,5 +1,5 @@ import fetch from 'isomorphic-unfetch'; -import { graphQlHost } from './config'; +import { store, graphQlHost } from './config'; import GraphQlQuery from './types/GraphQlQuery'; function fetchWithGraphQl(query: GraphQlQuery, token: string | null = null): Promise { @@ -12,7 +12,7 @@ function fetchWithGraphQl(query: GraphQlQuery, token: string | null = null): Pro ...authHeaders, Accept: 'application/json', 'Content-Type': 'application/json', - Store: 'default', + Store: store ? store : 'default', }, body: JSON.stringify(query), }).then((res) => res.json());