Why my GraphQL query is giving undefined?

Hi, im tweaking the pre purchase offers example to only retrieve an specific product, and it works fine but in the moment that i change the query it appears to gave me an undefined result

when i do this exact same thing with the query from the example it logs the expected result, but now it gaves me “undefined”

i have tried my query on the graphiQL app and works fine so… what do im missing?

thats the query:

 query(
      `query ($handle: String!) {
        productByHandle(handle: $handle) {
          id
          title
          images(first: 1) {
            nodes {
              url
            }
          }
          variants(first: 2) {
            nodes {
              id
              displayName
              price
            }
          }
        }
      }`,
      {
        variables: {handle:"llanta-pirelli"},
      },
    )

Hi @Mcastillo

Instead of deconstructing ({data}), rather return (res) => console.log(res) as res.errors will include the error returned from the api.

1 Like