HELP! Calling REST api with react and node.js

yousif999
New Member
3 0 2

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.

kconv
Tourist
3 1 0

I have the exact same question here!

0 Likes
gauravsr
New Member
1 0 0

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

 

0 Likes