Skip to content

Commit 6a4de83

Browse files
committed
10c tweaks
1 parent 5a95c4f commit 6a4de83

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/content/10/en/part10c.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ const fetchMovies = async () => {
5656

5757
For a more detailed introduction to the Fetch API, read the [Using Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) article in the MDN web docs.
5858

59-
Next, let's try the Fetch API in practice. The rate-repository-api server provides an endpoint for returning a paginated list of reviewed repositories. Once the server is running, you should be able to access the endpoint at [http://localhost:5000/api/repositories](http://localhost:5000/api/repositories). The data is paginated in a common [cursor based pagination format](https://graphql.org/learn/pagination/). The actual repository data is behind the <i>node</i> key in the <i>edges</i> array.
59+
Next, let's try the Fetch API in practice. The rate-repository-api server provides an endpoint for returning a paginated list of reviewed repositories. Once the server is running, you should be able to access the endpoint at [http://localhost:5000/api/repositories](http://localhost:5000/api/repositories) (unless you have changed the port). The data is paginated in a common [cursor based pagination format](https://graphql.org/learn/pagination/). The actual repository data is behind the <i>node</i> key in the <i>edges</i> array.
6060

61-
Unfortunately, we can't access the server directly in our application by using the <i>http://localhost:5000/api/repositories</i> URL. To make a request to this endpoint in our application we need to access the server using its IP address in its local network. To find out what it is, open the Expo development tools by running <em>npm start</em>. In the development tools you should be able to see an URL starting with <i>exp://</i> below the QR code, after the "Metro waiting on" text.
61+
Unfortunately, we can't access the server directly in our application by using the <i>http://localhost:5000/api/repositories</i> URL. To make a request to this endpoint in our application we need to access the server using its IP address in its local network. To find out what it is, open the Expo development tools by running <em>npm start</em>. In the console you should be able to see an URL starting with <i>exp://</i> below the QR code, after the "Metro waiting on" text:
6262

63-
Copy the IP address between the <i>exp://</i> and <i>:</i>, which is in this example <i>192.168.100.16</i>. Construct an URL in format <i>http://<IP_ADDRESS>:5000/api/repositories</i> and open it in the browser. You should see the same response as you did with the <i>localhost</i> URL.
63+
![](../../images/10/26new.png)
64+
65+
Copy the IP address between the <i>exp://</i> and <i>:</i>, which is in this example <i>192.168.1.33</i>. Construct an URL in format <i>http://<IP_ADDRESS>:5000/api/repositories</i> and open it in the browser. You should see the same response as you did with the <i>localhost</i> URL.
6466

6567
Now that we know the end point's URL let's use the actual server-provided data in our reviewed repositories list. We are currently using mock data stored in the <em>repositories</em> variable. Remove the <em>repositories</em> variable and replace the usage of the mock data with this piece of code in the <i>RepositoryList.jsx</i> file in the <i>components</i> directory:
6668

@@ -73,7 +75,7 @@ const RepositoryList = () => {
7375

7476
const fetchRepositories = async () => {
7577
// Replace the IP address part with your own IP address!
76-
const response = await fetch('http://192.168.100.16:5000/api/repositories');
78+
const response = await fetch('http://192.168.1.33:5000/api/repositories');
7779
const json = await response.json();
7880

7981
console.log(json);
@@ -118,7 +120,7 @@ const useRepositories = () => {
118120
setLoading(true);
119121

120122
// Replace the IP address part with your own IP address!
121-
const response = await fetch('http://192.168.100.16:5000/api/repositories');
123+
const response = await fetch('http://192.168.1.33:5000/api/repositories');
122124
const json = await response.json();
123125

124126
setLoading(false);
@@ -202,7 +204,7 @@ import { ApolloClient, InMemoryCache, createHttpLink } from '@apollo/client';
202204

203205
const httpLink = createHttpLink({
204206
// Replace the IP address part with your own IP address!
205-
uri: 'http://192.168.100.16:4000/graphql',
207+
uri: 'http://192.168.1.33:4000/graphql',
206208
});
207209

208210
const createApolloClient = () => {

src/content/6/en/part6c.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ Redux Toolkit offers a multitude of tools to simplify asynchronous state managem
597597

598598
<div class="tasks">
599599

600-
601600
### Exercises 6.16.-6.19.
602601

603602
#### 6.16 Anecdotes and the backend, step3

src/content/images/10/25new.png

70.3 KB
Loading

src/content/images/10/26new.png

36.9 KB
Loading

0 commit comments

Comments
 (0)