Another fish in the boat fetching data from Ittai is a little bit more up to date.
This is what we're using every day.
And here you have a question, right?
An example of fetch and data used in Fiji time
and Fiji is a modern way to load some data from a.
And actually, here I didn't remove the militia type request.
So you can compare codes that were old, like 10 years ago and now.
So here we can use fetch function and we just provide an input and get is the method inside fetch by
default, which means here we must provide just a year out.
The most important part is that fetch gives us back a promise, and this means that we can use here
then and catch to get some results.
So here we've got our response, but normally we want to convert our response to Jason.
In this case, we can easily use this data in Auckland.
This is why here we want to call rest of Jason, which is in the synchronous function, and it will
transform our response to Jason.
And after this, we can call then again and here we will get our data.
And now inside, we can work with this data.
For example, console.log success.
And here is our data.
And as you can see, this code is much smaller and easier to read than this old code with the simplicity
request.
And obviously, here were also rolled in there, and we also want to handle it here.
This is where here we can write dot cage and here we will get our error.
And now here we can write console.log azure and this will be triggered when we have an arrow.
Let's check now if this code is working.
I am relied in the page in the browser and as you can see, we're getting a success.
And here are our response.
And as you can see inside network, we have our reps request and the type is fetch.
And here is our response, which actually means this code is working exactly the same.
But it is based on promises, which means we can easily mix this code with any other asynchronous operations
which are based on promises.
For example, if you have two or three sources, for example, if you have several sources of data,
you can easily combine them together because they are all based on promises.