Skip to content

How to access the magento 2 graphql api using react js

I am developing a headless eCommerce application for my resume, so here is my question how to access the magento2 product collection graphql API which is running on a server using react js which is running on localhost:3000, I don’t understand why it is blocking the request and please explain this one or refer any reference to get understand this and I am attaching the console error which I got while connecting

enter image description here

index.js

const link = createHttpLink({
  uri: 'http://192.168.1.16/graphql',
  headers: {
    "Access-Control-Allow-Origin": "http://192.168.1.69:3000",
    "Access-Control-Allow-Methods": "GET, POST, PUT",
    "Access-Control-Allow-Headers": "Content-Type"
  },
  mode: 'no-cors',
});


const client = new ApolloClient({
  link,
  cache: new InMemoryCache(),
});