Creating checkout instance storefront api with Apollo's useMutation

omergeva
New Member
1 0 0

Hi,
I'm trying to create a checkout instance using the useMutation hook.
I know my client is set up properly as I'm able to make queries for items in my store.
Whenever I call the function to create the checkout instance, I get 
Error: Unexpected end of JSON input

Appreciate the help!!

Calling query:

 

  const [createCheckout, { data, loading, error }] = useMutation(CHECKOUT_CREATE_MUTATION);
  const handleOnAddToCart = async () => {
    await createCheckout();
    await console.log(data);   
  }

 

Checkout query: 

 

  const CHECKOUT_CREATE_MUTATION = gql`
  mutation checkoutCreate {
    checkoutCreate(input: {}) {
      checkout {
        id
      }
    }
  }
  `;​

 

 (I was originally trying to create it using an actual line item, but after that didn't work I figured to just try to create the checkout instance first).

0 Likes