We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: HELP! Calling REST api with react and node.js

HELP! Calling REST api with react and node.js

yousif999
Visitor
3 0 4

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.

Replies 2 (2)

kconv
Shopify Partner
6 1 0

I have the exact same question here!

gauravsr
Visitor
1 0 0

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