HELP! Calling REST api with react and node.js

I am following the tutorial on How to build a shopify app with Node.js and React. In this tutorial, they use GraphQL Admin API to make queries to shopify. GraphQL, however, is not fully complete and there are some components are only avaliable with the REST Admin API.

In my case, I want to retrieve all pages in a given store. This is what I have so far

const url = 'https://example-store.myshopify.com/api/pages.json';
fetch(url, { method: "GET", })
    .then(response => response.json()).then(json => console.log(json))

I keep getting a 404 error, and being blocked by “CORS” I tried setting up a koa-router, but nothing is working

I there’s something I am doing wrong, or another/easier method, please do let me know.

4 Likes

I have the exact same question here!

Did you try setting up CORS? https://reactjs.org/docs/cross-origin-errors.html