OK, so now that we are done with understanding the concepts, whatever we have understood, like async
await promises, Brian Cage, now we will implement all of that in our project.
But first of all, we will define this function.
We will make this function, which we call it on the on click button that does get weather info.
Who will find this function here?
That will be.
Constantly back.
But they're in for and this will be equal to a federal function.
And so this will be some content to define the function, and now let me just tell you how you will
use it and the use effect took use effect took of.
This expects function to function basically.
All right.
And here you will be provided and dependency.
It seems that the use effect we want to call this function, which is the good.
But they're informed because we want to call this function on every page.
The fresh and the dependency era is empty, which means that this function will be called only when
the page refreshes for the first time, like for the first time, and then it will not like only one,
this functional scooter.
And after that, it will be not executed just once it would be executed.
Right now, let's go to the.
Get other info function, so here we will, right to try and catch blocks, which we just discussed.
So this will be having curly braces inside this.
We also have a catch for that, so we will define it later as inside the try and inside the tile.
Let me just tonight let you wait until we hear we'll provide you all you are.
All means the endpoint, the API endpoint, which will be which will be fitting data for us.
OK, so here we'll be using that.
So let me take you to the browser where from where we'll find this.
We'll find it here.
So this is the end point, basically.
And.
Let me just comment.
Mr.
Yes.
So let me find my EPA.
I've posted it here.
I've commented it invested here.
Give it a little space, little clean.
Let me just go to the browser and let me find my key inside my Yankees.
So this one, I'll be using one.
Then I'll go back to my I.D..
And had they stood?
Alright, alright, alright, alright, now let me check if this is working inside the.
Browser.
Who is today inside the city named, we will provide a city name, which is.
And by.
OK, RPA is worth considering we just copy this, you know, and this will be used by us.
Now, let's go back to the business to be a good, and we'll provide you all here.
OK.
There the other.
And we did build this coming.
Now what we're going to do is how do we have provided this name Mumbai by ourselves?
But I warned us that it's time to get past there because the certitude the city, which the user researching
that should be parsed here and that data should be returned, respectively for that.
Think ahead.
I'll be providing backpacks because I'll be using ActionScript five insiders.
That will be the.
Like the rebel I'd be passing here, so I will delete Mumbai and here I'll be providing or or sign.
And clearly racist inside this do, providing the search.
All righty, all righty.
So next, let me just turn on the word breast.
Looks clean.
Looks clean and next will go on somewhat dirty.
So inside this now will capture the desert, so like there is.
So this is the variable which really capturing that there was none of it.
We are using of it, which means why we are using our weight because we are waiting for that data to
come back and we are passing that.
You are allowed inside the fetch.
Next, we are converting that data to Jason, so that will also take some time.
So I'll wait for the restart.
Jason, this raises variable and dark descent will convert into Jason form if it's not in Jason.
Like this is the precautionary thing, right?
So if that does not convert into Jason, so this will convert into Jason.
All righty.
So I think now we got the data and after this, after the pride thing, we will write the catch.
If there is an error we like and get inside, this feels like.
At our award, spelling.
And people just try eat like you can possibly also catch an error.
So does that would be a console?
Just log it will console.log the error, why are?
Mistake of her.
All right.
So this will console and log the error message.
So let me just console and console log the data console log log.
That data or data is what is converted into Jason, right, so that I will be converting, so now I
have to save this.
And let me start off the server.
So let me start the sidebar.
So because we need to run it in on browsers, let me just go to the website.
I mean, the directory and that was that then will write and PMS sorry.
So this will start our server.
And it can take a few seconds because.
It generally takes that time, so I hope this is clear to you because now we have.
The API and the endpoint is also go.
So this is giving us the hope to receive the data.
Now we are getting it out of hand, which is unresolved, unexpected as our word that is of it.
So what do you mean by this?
Because I've already told you you cannot use of it if you are not using this thing like a weight is
always used inside a thing.
So here you will make this function async by.
Providing a sink.
Alike is think.
Now, if I save it, I should look.
All right.
This works and let us go to the browser.
And let me just.
And let me go to the console, select me to see if something is being returned or not.
Yes, yes, yes, we are getting data.
That's what we were expecting, right?
We are getting data.
So.
The wind speed and everything we are getting, that is what we wanted to check on, API is working fine,
we are getting it.
Like according to need.
So that's all.
Now we will move, move further.
Okay?
How do we make this to the side and the side?
Yes.
Agnes will now be unable to like view properly.
So now we are.
We want this data like, what do you know?
The data is very much scattered for like there are areas that are object inside out is how you will
get the data, how you will fetch that data.
So that's a challenge.
We need to understand the structure and then you need to just get that data.
So now we'll get the data one by one.
We'll be structure this so that this quality is restructuring, that it will be the right one by one.
And get that data.