DEV Community

Cover image for 🍝 Cooking a Deliveroo clone with Next.js (React), GraphQL, Strapi and Stripe - 🏠 Restaurants list (part 2/7)

🍝 Cooking a Deliveroo clone with Next.js (React), GraphQL, Strapi and Stripe - 🏠 Restaurants list (part 2/7)

Ryan on February 04, 2019

This tutorial is part of the « Cooking a Deliveroo clone with Next.js (React), GraphQL, Strapi and Stripe » tutorial series. Table of contents ...
Collapse
 
chuanman2707 profile image
chuanman2707

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

Collapse
 
ryanaz profile image
Ryan

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

Collapse
 
hipertrix profile image
Antonio M Ferreira • Edited

Great tutorial!

I had to comment apart to run here, I'm using Postgres and I also changed _id to id.

//pages/index.js

//searchQuery
// const searchQuery = restaurants.filter(query =>
//   query.name.toLowerCase().includes(search)
// );
const searchQuery = restaurants;
Collapse
 
sankar2389 profile image
sankar

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

Collapse
 
ryanaz profile image
Ryan

Could you post the error you are seeing so I can take a look?

Collapse
 
ryanaz profile image
Ryan

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

Collapse
 
sankar2389 profile image
sankar • Edited

Attached the screenshot ibb.co/pXphg33

Thread Thread
 
ryanaz profile image
Ryan

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?

Thread Thread
 
sankar2389 profile image
sankar

Yes, my mistake. I got the output without downgrading graphql version itself. Thanks

Collapse
 
razvancretu profile image
RazvanCretu

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?

Collapse
 
gameoverwill profile image
Wilfredo Pérez

Awesome, part 2 finished. I can't wait to start part 3.