So let's navigate the app context.
Let's scroll up, first of all, let me it just so you don't think that I'm cheating, just so you know,
that is definitely going to be added with our interceptors.
And I guess let's set up the request on force.
So and then I'm going to go with my offer switch, not interceptors when we want to go with the request
one we can use.
And then as we saw in the docs, we want to pass here two functions.
So let me set up this one right from the get go and then we'll worry about the rest of the stuff.
So and once I have them in place for the first one, I need to come up with some kind of parameter.
In my case, that is going to be config, just like in the box, and we want to return that config.
So let's first start by pretending otherwise, it's very easy to forget.
And then we go with config, then headers, then that and then common and right after common.
I want to go with my authorization just like we had in our global setup, and that one will be equal
again to our token.
So better.
And then what's access the state and then token?
And as far as the response error, it's pretty much going to be generic.
So we're going to go with error.
And then we want to go with a turn that promise.
That and a reject, and let's pass here are as well.
Let's save it.
And in order to speed this up a little bit, I'm going to copy and paste everything like so.
And this is going to be for response.
So one by one, let's change the hours.
That's the downside of copying pasting because it's very easy to make some kind of silly mistake.
So let's first change this one to a response one.
Now, this is not going to be config.
I'm just going to say response.
I believe that's what they have in the docs.
We don't need this line of code.
We're not going to be handing this, which simply want to return the response.
Correct.
Not once this one is in place.
Knowledge deal with error because this is going to be way more interesting as far as the response one.
And first, I want to just log our online response.
And second, I know that there's going to be a status one on the response.
And here's what I want to do on a status.
I want to check if it's for one, then I want to log something in capital case and if not, well, then
we'll just move on and set up the error.
So in here, let's say if error and not a response and the status is equal to that for one.
So that's the one that we're dreading.
Then let's do a massive console.log.
So let's say you're logged online off an error.
And if it's just a typical error, well, then we won't do anything.
And once we have both interceptors in place now, let's take them out for a test drive.
And I think at this point, I can remove those talks like I made my case and let's move this as well
and mine for time being, I think I can comment about the error response in our update user.
I think it's not that useful.
So let me navigate back to my application online.
Let me refresh state is are you?
So of course I have a typo.
I mean, over here it should be state.
Not state.
OK, let's try one more time.
OK, I have the user.
Awesome.
Let's first Senate just so we can see whether everything works.
In this case, I'm going to go with John.
I get back my update user.
OK.
Clearly, see that I'm sending the Barrett token.
Awesome.
Now let's worry about those responses.
So I'm going to go here to a log and here I'm logging the data that I'm getting back.
All right.
And now let me remove the field first.
Let's send it now.
Notice we're just getting back the error response log.
Correct.
So the status is 400, and the message is please provide all values.
And essentially, this is what we'll be setting up here in the alert.
So this is what we'll say.
Please provide of ours again.
It's kind of hard to see with the 400 responses, meaning the please provide all of our sins.
That's what we are doing on the front, and that's why we commented it out.
I know I'm repeating myself, but I thought that it is important to mention that now what's more interesting
for me is what is going to happen.
What do you think if we remove the token?
So how we can do that?
Well, we can either comment this one out here or we can remove it from the state.
I mean, that is really up to you, I think.
I'm just going to come on this one out in the interceptor.
So again, I'm talking about the request one.
And now let's try to make a request.
So let's send it.
And now we have a different one.
Now we have off error, which means that we are not authorized to make these requests.
And this is the entire point why we were setting up those interceptors.
Because again, we want to control what is the our response because we clearly want to keep track of
the error responses and then we want to make decisions based on those responses and what interceptors
in this case.
More specifically, response interceptor allows us to do is to set up one logic for multiple requests.
Again, this is not just for the profile.
San Diego is going to be for ad jump.
All jump start.
So that way we have our code in one place.
And then if that arrow gets triggered, then our response is pretty much going to be the same.
And then that way, if we want to make some changes, we need only change that in one place.
Hopefully, that is clear, and now we can start finally setting up our update user functionality.