1
00:00:00,150 --> 00:00:05,220
Another fish in the boat fetching data from Ittai is a little bit more up to date.

2
00:00:05,440 --> 00:00:07,290
This is what we're using every day.

3
00:00:07,560 --> 00:00:09,060
And here you have a question, right?

4
00:00:09,060 --> 00:00:12,330
An example of fetch and data used in Fiji time

5
00:00:15,540 --> 00:00:19,320
and Fiji is a modern way to load some data from a.

6
00:00:20,100 --> 00:00:23,400
And actually, here I didn't remove the militia type request.

7
00:00:23,550 --> 00:00:27,600
So you can compare codes that were old, like 10 years ago and now.

8
00:00:27,840 --> 00:00:34,710
So here we can use fetch function and we just provide an input and get is the method inside fetch by

9
00:00:34,710 --> 00:00:38,040
default, which means here we must provide just a year out.

10
00:00:38,340 --> 00:00:44,250
The most important part is that fetch gives us back a promise, and this means that we can use here

11
00:00:44,250 --> 00:00:46,650
then and catch to get some results.

12
00:00:46,890 --> 00:00:52,440
So here we've got our response, but normally we want to convert our response to Jason.

13
00:00:52,620 --> 00:00:55,530
In this case, we can easily use this data in Auckland.

14
00:00:55,770 --> 00:01:01,500
This is why here we want to call rest of Jason, which is in the synchronous function, and it will

15
00:01:01,500 --> 00:01:03,690
transform our response to Jason.

16
00:01:03,930 --> 00:01:08,010
And after this, we can call then again and here we will get our data.

17
00:01:08,250 --> 00:01:10,800
And now inside, we can work with this data.

18
00:01:10,980 --> 00:01:13,500
For example, console.log success.

19
00:01:13,500 --> 00:01:14,880
And here is our data.

20
00:01:15,210 --> 00:01:21,450
And as you can see, this code is much smaller and easier to read than this old code with the simplicity

21
00:01:21,540 --> 00:01:22,050
request.

22
00:01:22,410 --> 00:01:27,030
And obviously, here were also rolled in there, and we also want to handle it here.

23
00:01:27,270 --> 00:01:31,230
This is where here we can write dot cage and here we will get our error.

24
00:01:31,440 --> 00:01:37,020
And now here we can write console.log azure and this will be triggered when we have an arrow.

25
00:01:37,320 --> 00:01:39,480
Let's check now if this code is working.

26
00:01:39,690 --> 00:01:43,500
I am relied in the page in the browser and as you can see, we're getting a success.

27
00:01:43,710 --> 00:01:45,420
And here are our response.

28
00:01:45,690 --> 00:01:50,520
And as you can see inside network, we have our reps request and the type is fetch.

29
00:01:50,760 --> 00:01:55,860
And here is our response, which actually means this code is working exactly the same.

30
00:01:56,130 --> 00:02:02,940
But it is based on promises, which means we can easily mix this code with any other asynchronous operations

31
00:02:02,940 --> 00:02:04,590
which are based on promises.

32
00:02:04,830 --> 00:02:09,870
For example, if you have two or three sources, for example, if you have several sources of data,

33
00:02:10,020 --> 00:02:14,460
you can easily combine them together because they are all based on promises.
