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.

Can't get MetaObjects

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)