Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
M2_CONFIG_HOST=https://www.your-magento-site.com
M2_CONFIG_HOST=https://www.your-magento-site.com
M2_CONFIG_STORE=default
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/fetchWithGraphQl.ts
Original file line number Diff line number Diff line change
@@ -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<any> {
Expand All @@ -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());
Expand Down