Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Rugh <[email protected]>
  • Loading branch information
sirugh committed Dec 20, 2024
1 parent bde37e8 commit 4fa7c7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/commerce.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/prefer-default-export, import/no-cycle */
import { getConfigValue, getCookie } from './configs.js';
import { getConfigValue, getCookie, getHeaders } from './configs.js';
import { getConsent } from './scripts.js';

/* Common query fragments */
Expand All @@ -22,11 +22,12 @@ export const priceFieldsFragment = `fragment priceFields on ProductViewPrice {
export async function commerceEndpointWithQueryParams() {
// Set Query Parameters so they can be appended to the endpoint
const urlWithQueryParams = new URL(await getConfigValue('commerce-endpoint'));
urlWithQueryParams.searchParams.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
urlWithQueryParams.searchParams.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
urlWithQueryParams.searchParams.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
urlWithQueryParams.searchParams.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
urlWithQueryParams.searchParams.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
await getHeaders('pdp').then((headers) => {
Object.keys(headers).forEach((key) => {
// TODO: is it OK to apply all headers as query param even if they include things like api-key and content-type which was not previously a query param?

Check failure on line 27 in scripts/commerce.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 157. Maximum allowed is 100
urlWithQueryParams.searchParams.append(key, headers[key]);
});
});
return urlWithQueryParams;
}

Expand Down
1 change: 1 addition & 0 deletions scripts/initializers/pdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ await initializeDropin(async () => {
setEndpoint(await commerceEndpointWithQueryParams());

// Set Fetch Headers (Service)
// TODO: is it OK to apply all headers even though the commerceEndpointWithQueryParams also applies them?

Check failure on line 32 in scripts/initializers/pdp.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 107. Maximum allowed is 100
setFetchGraphQlHeaders(await getHeaders('pdp'));

const sku = getSkuFromUrl();
Expand Down

0 comments on commit 4fa7c7e

Please sign in to comment.