Welcome back, guys.
Welcome to the first video where we are starting working on the project, so we are not actually going
to code much in this video because he's going to be getting the getting the first API call.
And I'm going to talk about the OMV API.
So this is a free you need to go here.
And if you want to be a patriot, give them my money.
That's good.
For the moment.
It's free so you can use register your name, all those things and they will shoot you back an email.
So make sure that you check the email, even just spam or junk.
It will be somewhere and they will give you the key and they will give you the curious API, how you
can look for a particular movie and make sure that you click on this one.
So don't use mine because my can be easily they can block it because you can have more than a thousand
requests per day.
You can't have actually more than a thousand requests per day.
But if somebody else is using, you can easily make more than one thousand and they can block money
by now.
Why is API?
Aiba is a special key, like a password.
They will track you, they will know how what you're doing with it and stuff like that.
Also, you need to tell them that you are building something here like a for web development.
You can say, you know, testing of the development app and stuff like that.
Give them an explanation.
Nice.
So going back here with your you're going to put your key here and this is actually the end point in
the end point is actually where you can put parameters here.
The different parameters we can use.
This one is saying optional.
Right.
We will use the AI parameter that's going to be for the ID.
So we get a search movie bag and we're going to say yes by search movie, by the title.
That's cool.
But let's go to back to the main controller here.
So first things first.
We need to create async function, right?
And let's say a Test API in here.
I'm going to pass the query, this query actually later on.
So this will be just for testing later on.
This Quiller query will come from the search.
Also, make sure that you are always running in the background from now on and running it because you
need to have these live server going on here in order when we do some changes.
You want to see those changes here right now running it?
I'm not going to show you.
I'm not going to tell you anymore from now on.
Good.
Now, the query, we're going to call this function here Test API.
We Batmen, for example, you can put any name of the movie you want in here.
We will use the fetch method.
Right.
Remember, we use that such method.
And let's go to your they will give you the email.
Just copied this one here and paste those here.
Make sure that you select them in common them out.
Right.
API key.
You don't need this one.
And here we go now, I'm going to copy this one, we're going to change it a little bit.
So this actually should be put.
I'm going to go back.
I'm going to make it in the literal string, right.
Template literals.
Now, the fetch, we usually save it in somewhere.
So I'm going to say consed result and away.
Right, because this is a real API call.
Now here my key is that one what we can do, we can just make more things interesting.
Sorry about that.
So const key and we will store this one inside here as a string.
My key if I can just do it after it is I can just added here now so I'm going to leave this one for
now.
So I'm going to say const Hanzo log result.
Now by the way, this will return.
This will return a particular movie based on the idea, right?
This is the movie idea, I don't know which movie is this is not Batman because we are not just using
the query here.
Right.
So concerned like the result.
You know, let's see what's happening if we have some results, by the way.
Good.
Now, we do have here we acquiring this one API and think the status is 200 in.
Actually the data is here in the body readable stream.
So we passing the headers.
Everything is working pretty much as you should be in the state.
It is 200.
That means everything is good.
Now, how are we going to draft the data?
Remember how we did it?
So we said console sorry, const data here.
And what we have done is actually we say a wait in result that JS so we pass it back.
Now I'm not going to print out the result, it's going to print out the data here and I'm going to save
it.
Here it is.
Now I have the data for that particular movie and I have a lot of things here.
The actors, the box office, the production.
We're going to go through all of this here, the IMDB, actually the ID.
That's the ID here.
Nice.
But what if I want to query this Batman here?
OK, so I'm just going to copy this.
The entire thing.
No, change it like this.
I'm going to paste it in here.
I am going to delete until this questionmark and I'm going to say s here.
S means for search and I'm going to pass the query.
Nice.
So let's see what will happen if this is actually going to work.
Now the data so we having an object search object with ten with ten elements.
Right.
Actually we have area of ten objects and we have the Batman Begins.
So this is pretty much what these are.
IMDB API will give it to you.
So we using this parameter here.
Right.
So this is I'm doing everything from this description here in the documentation to have.
They also have the examples and yeah, it's free from 2017.
I hope it's going to stay like this so you can test it out.
Cool.
So we know how to query the week to make up our own query and then just fetch that API and store the
result in the data.
Now what if I want to use this data to be more meaningful?
Right.
So it's stored here in this search area.
So what I can do, I say search, save it.
And now I will able to see the entire area of 10 objects.
So these are everything that is grabbing from that API.
So as I told you, I'm not sure if I told you before, but it will this API will provide your test results
for the search.
There are probably 300 or 400 other results.
Right.
For example, if we just can't unlock the result, we will be able to see we will be able to see how
many, OK, we may not be able to see at the moment, but pretty much there are more results.
But it's going to give you the ten results in those test results.
We can use them later on.
So this is pretty much how we're going to grab the data from the API.
Now, one more thing that I want to make this thing more secure from errors.
Try and catch.
Right.
So I just copy this one error here and I'm going to stay alert error, OK?
And I'm going to step back here.
The code either try block, so try and catch.
So now it should work everything the same.
But if we just change, let's put it here, double X here at type network error.
If we change, maybe, maybe if we change the key here to SS, it will not give undefined, it will
not give us an error because the fetch is working a little bit different than excuse.
So if you, if you were using the axes you will see that one is popping right through here.
Right.
But it's cool.
Now we are at least secure that something if there is something wrong here it will be catched here.
Good.
So this was the first our first API call.
Right.
And from now on we will we will work on our project.
So, yeah, at least we are just trying to get the data and it's working cool.
And after that we can use this to build this application here.
So thank you very much.
I will see you in the next one.