Skip to content

Commit

Permalink
Headers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaschenko committed Feb 14, 2025
1 parent 324a5b2 commit 81681fa
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions blocks/targeted-block/graphql.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { fetchGraphQl, setFetchGraphQlHeaders } from '@dropins/tools/fetch-graphql.js';
import { fetchGraphQl, setFetchGraphQlHeader } from '@dropins/tools/fetch-graphql.js';
import { getHeaders } from '../../scripts/configs.js';

const addCartHeaders = async () => {
const cartHeaders = await getHeaders('cart');
cartHeaders.keys().forEach((key) => {
setFetchGraphQlHeader(key, cartHeaders[key]);
});
};

const getCustomerGroups = async () => {
try {
// setFetchGraphQlHeaders(await getHeaders('cart'));
addCartHeaders();
const response = await fetchGraphQl(
`query {
customerGroup {
Expand All @@ -24,7 +31,7 @@ const getCustomerGroups = async () => {

const getCustomerSegments = async () => {
try {
// setFetchGraphQlHeaders(await getHeaders('cart'));
addCartHeaders();
const response = await fetchGraphQl(
`query {
customer {
Expand All @@ -47,7 +54,7 @@ const getCustomerSegments = async () => {

const getCartRules = async (cartId) => {
try {
// setFetchGraphQlHeaders(await getHeaders('cart'));
addCartHeaders();
const response = await fetchGraphQl(
`query TB_GET_CUSTOMER_SEGMENTS_CART_RULES($cartId: String!){
customerSegments(cartId: $cartId) {
Expand Down Expand Up @@ -89,7 +96,7 @@ const getCatalogPriceRules = async (sku) => {
}
}
`;
// setFetchGraphQlHeaders(await getHeaders('cart'));
addCartHeaders();
const response = await fetchGraphQl(
query,
{
Expand Down

0 comments on commit 81681fa

Please sign in to comment.