createCart returns 404 with HTML response

createCart returns 404 with HTML response

AlexanderWeb
Shopify Partner
16 0 2

When the following mutation is invoked I get an error which returns an HTML response:

 

const graphQLClient = new GraphQLClient(endpoint as string, {
  headers: {
    "X-Shopify-Storefront-Access-Token": storefrontAccessToken,
  } as any,
});

 

export async function addToCart(itemId: string, quantity: string) {
  const createCartMutation = gql`
    mutation createCart($cartInput: CartInput) {
      cartCreate(input: $cartInput) {
        cart {
          id
        }
      }
    }
  `;

  const variables = {
    cartInput: {
      lines: [
        {
          quantity: parseInt(quantity),
          merchandiseId: itemId,
        },
      ],
    },
  };
  try {
    await graphQLClient.request(createCartMutation, variables);
  } catch (error: any) {
    // error happening in this catch
    throw new Error(error);
  }
}

 

Screenshot 2023-06-03 at 19.40.12.png

Screenshot 2023-06-03 at 19.40.21.png

  

 
Replies 0 (0)