Skip to content

Commit 90c459e

Browse files
committed
done with react get all listings
1 parent e44ed1a commit 90c459e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/content/create-all-listings-pagge.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ chapter: Get All Listings
1111

1212
In this chapter we will create the landing page that will get all the listings.
1313

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:
1515

1616
```javascript
1717
import React from "react"
@@ -58,11 +58,11 @@ export default Index
5858

5959
🥑 First off we are using the `useQuery` hook from the Apollo library to get all the listings.
6060

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.
6262

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.
6464

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:
6666

6767
```javascript
6868
export const GET_ALL_LISTINGS = gql`
@@ -79,7 +79,7 @@ export const GET_ALL_LISTINGS = gql`
7979
`
8080
```
8181

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.
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.
8383

8484
If all goes well, you should have this:
8585

0 commit comments

Comments
 (0)