All right.
So that was the global setup, and now we're inching closer to our actual setup, where what's really
cool in action here is that we can set up the instance.
Now how does that look like?
Well, we grab the import, which is going to be Axios.
Then we go dot create.
And then you can set up a bunch of goodies over here.
Now, if you want to find out more options, then yes, please navigate the docs.
But in my case, I'll showcase the base URL, which you're going years.
So essentially in the process will omit adding this API version one to all of our requests.
Because remember, I mean, that's what the server is looking for.
And at the moment, we have been hard coding that and also we can go here with a header just like we
did previously here directly in the request.
So now we set up the headers and authorization.
And what's really nifty now notice how we can just use this off edge.
Now what that means is that with my talk request, I don't have to send the bear token.
So let's try to set this one up where I'm going to go back to app context.
And yes, I will remove these ones because you have to read me.
So you can always access them.
So let me remove this one.
And now it's set up that auth fetch.
So let's go with Konst and then off fetch.
Now that is equal to Axios.
So the instance of create an alert and here we want to pass in the object now inside of the object,
let's go with base URL.
So something you want to add to all of your requests, which are going to, in my case, is going to
be API and version one.
And yes, as a sign up, for example, if you want to set up, I don't know a request for all the jobs,
just go here and say jobs like so now in our case, I'll be adding to both to the update one as well
as the jobs one.
So I'm not going to do that, but it's definitely an option if we want to go with comma.
And then let's set up the headers.
So we're going to go here and we'll pass in the authorization again authorization.
My apologies.
Yes, I'm pretty bad with those type of words, for example, authorization.
So I do need to repeat it quite a few times while I'm recording.
So bear over here.
And then let's also grab the token state and then token.
And once we have this one in place, let's keep on scrolling and where I have the update user instead
of using Axios now, I want to go with what I want to go with or fetch, and I'll purposely leave this
one as the Axios one.
And what you'll note is that if we go back again to our browser and I'm going to go back to John in
this case, what's really, really cool?
Well, first of all, it's going to say update user and cannot find.
Sure, let's troubleshoot together what I have off fetch.
And yes, of course.
So notice how I added the API in version one and then I kept it over here.
So now, since it is my base, you can actually test that out over here where you can see the Iraq correct.
So we have this API version one API, version one and then off and that user.
And as a very, very quick sign on since I've been getting this question in my node course.
So some students have been asking why this one goes to localhost 3000, not 5000.
Well, when we need to keep in mind is that when we set up the proxy, it's not like we are changing
the entire setup.
Meaning that proxy just adds some fullbacks.
So in this case, we're still making a request to 3000.
But then if we cannot get that resource, then we try out, Hey, is there something on the local host
5000 or whatever?
We set up the proxy?
Hopefully, that is clear.
And now let me fix my tiny bug over here, where our more this one.
And then let's do it one more time.
I'm just going to leave it as Peter.
And then let's send it.
And now in order something where update users 200.
So I don't think I have to showcase that that barrier token is present over there.
But if you take a look at the React Thoughts Project one.
And if we keep on scrolling, the Birtukan is nowhere to be found.
And that's exactly what I want as far as making my request.
Because again, I know I said this already in the previous video, but the last thing you want is just
start standing out your tokens left and right.
And now that's how we can set up a instance using access library.