This tutorial is part of the « Cooking a Deliveroo clone with Next.js (React), GraphQL, Strapi and Stripe » tutorial series.
Table of contents
...
For further actions, you may consider blocking this person and/or reporting abuse
I don't understand this part
RestaurantList.getInitialProps = async ({ req }) => {
const res = await fetch("https://api.github.com/repos/zeit/next.js");
const json = await res.json();
return { stars: json.stargazers_count };
why you need to fetch query from
https://api.github.com/repos/zeit/next.js
This can actually be removed, it was only in code as an example for fetching data in NextJs and has nothing to do with the application. I’ll take it out of the code base to prevent confusion
Great tutorial!
I had to comment apart to run here, I'm using Postgres and I also changed _id to id.
//pages/index.js
When I try this query
{
restaurants {
_id
name
}
}
in localhost:1337/graphql , I still got an error. Even though I downgraded my graphql version to 0.13.2
Could you post the error you are seeing so I can take a look?
I just realized my gists for the actual code didn't transfer through, you may want to take a look now and retry. Let me know if you have an error still and Ill try to help you fix it
Attached the screenshot ibb.co/pXphg33
Thanks for the screenshot, did you choose your DB as MongoDB in the Strapi setup or a different option? If you chose a different option you may need to use id instead of _id, can you try changing it to id and seeing if your able to pull results?
Yes, my mistake. I got the output without downgrading graphql version itself. Thanks
I literally followed all your steps and I get this error when I run my frontend:
error - ./node_modules/@apollo/react-hooks/lib/react-hooks.esm.js
Module not found: Can't resolve 'apollo-client' in 'C:\Projects\frontend\node_modules\@apollo\react-hooks\lib'
Could someone help me?
Awesome, part 2 finished. I can't wait to start part 3.