Can't get MetaObjects

Jeffrey13
New Member
4 0 2

Hi, I m building a storefront with Hydrogen.

 

I just created a metaobject but i m getting an error when i try to fetch it with graphql. It's weird because i allowed the acces from storefront.

 

It work perfectly with the graphiQL explorer app installed in my shopify store:

 

Jeffrey13_0-1675457271725.png

 

but when i fetch it with this code 

 

import { gql, useShopQuery } from '@shopify/hydrogen'
export default function Tester() {
  const { data } = useShopQuery({ query: METAOBJECT_QUERY })
  return <div>Test</div>
}
const METAOBJECT_QUERY = gql`
  query metaobj {
    metaobject(id: "gid://shopify/Metaobject/20873484") {
      id
      fields {
        key
        value
      }
    }
  }
`

 

I get this error  " Failed to connect to the Storefront API: 200 OK "

Replies 0 (0)