You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/create-all-listings-pagge.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ chapter: Get All Listings
11
11
12
12
In this chapter we will create the landing page that will get all the listings.
13
13
14
-
Open up the index.js file under the pages directory and add the following:
14
+
Open up the `index.js` file under the `pages` directory and add the following:
15
15
16
16
```javascript
17
17
importReactfrom"react"
@@ -58,11 +58,11 @@ export default Index
58
58
59
59
🥑 First off we are using the `useQuery` hook from the Apollo library to get all the listings.
60
60
61
-
🥑 Then we have two if statements that will return some HTML for us if loading or error is true. This is nice because we do not have to do any fancy stuff to determine if the API is fetching data for us or the QUERY failed.
61
+
🥑 Then we have two if statements that will return some HTML for us if `loading` or `error` is true. This is nice because we do not have to do any fancy stuff to determine if the API is fetching data for us or if the QUERY failed.
62
62
63
-
🥑 In our return block, we have the <LandingHeader/>component with an `imgURL` and text props. While we loop of over the listings and pass through the data of each listing as props to our `<ListingCard/>` component.
63
+
🥑 In our return block, we have the `<LandingHeader/>`component with an `imgURL` and text props. While we loop of over the listings and pass through the data of each listing as props to our `<ListingCard/>` component.
64
64
65
-
Next up we need to create the schema document for the `GET_ALL_LISTINGS` query, so head over to the Queries.js file under the graphql directory and add the following:
65
+
Next up we need to create the schema document for the `GET_ALL_LISTINGS` query, so head over to the `Queries.js` file under the `graphql` directory and add the following:
🥑 We are calling the getAllListings query that will give is the above fields to pass into the listing card. Note we are only telling the API to gives exactly the fields we want.
82
+
🥑 We are calling the `getAllListings` query that will give is the above fields to pass into the listing card. Note we are only telling the API to gives exactly the fields we want.
0 commit comments