So now that we need a piece of state to hold our data, so for that purpose, maybe be just using the
use data, which he has started about.
So let's just import I use data from a React module and create a concert.
Those and a set of function set tools.
And we will be having the initial state value as.
And issue of state value as an empty area, because initially we don't want any data, not right.
And the next step is to create a function that is going to facilitate API.
And so let's create a function with guns to get user is going to be able the function and due to the
condition that doesn't already do us, we need this function to be an agent function.
So that raises the weights when we put up an object, you are in front of an API call to so that it
can resolve a promise.
What I'm talking about just said now let's create a concept for that first try, catch, block and catch
if any error occurs, which it shouldn't, hopefully just console blogger added.
OK, in attack in a trademark, let's just go and a response which is going to be a promise from our
search method.
And the API call is.
S GDP scores API dot com reactors project.
And this is going to return a promise, and let's just put up and await key word right in front of us.
But matter.
No, it is going to give us a promise right now.
Let's create the concert dose, which should be equal to.
And then we will again be putting up a great keyboard.
And there should be a response.
Dr. Jason.
So what we need is to convert the theater into adjacent formats so that we can actually use that data
because unless and until it's in JASON format, it's of no use to us.
No, that's just said to function and provide tools.
Okay.
So we have successfully implemented a try catch block.
Now we need to call this function and the best place might be the use effect, right?
So let's just call it nine years if I took.
OK, use, eat or whatever.
Right?
And of course, mine between no use.
Effect.
And and say the use effect is another callback function, which you're just going to get use of.
Now you might remember that there's a second argument which we can pass, which can be a specific argument
that we want the company to render only when that company, only when the business changes.
But for this particular project, we'll just pass it in theory.
So you know what happens when you pass an empty area whenever he was an entity?
This function is going to be called only once, and that is when the component is going to mount.
So in hit safe and we have successfully added dynamics or API to our app.
So let's move forward.