Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

createCart returns 404 with HTML response

createCart returns 404 with HTML response

AlexanderWeb
Shopify Partner
18 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)