OK, so we know we need to send up an authorization header to retrieve the data back from this particular
method and what we make use of to achieve this is an EDV interceptor.
So let's go back to Vaskov and create another one of those, and I'll just clean up the tabs again at
the top and inside our core project, inside our client app, I should say, inside source, inside
app, inside core.
We've got an interceptors folder.
So let's add another new interceptor.
And this one will call JWT Interceptor.
Dotts.
T.
S and we don't get any template assistance from Angella with this one, so we'll just create this manually
and we'll say export class JWT interceptor.
And this is going to implement.
The HTP.
Interceptor.
And I'm going to do this right now because I forget this quite a lot and we need to make this injectable.
So let's bring this in from Angelico as well.
And let's go ahead and try and implement this particular interceptor and will implement the interface,
and it's done the same thing it did last time, airport in all sorts of local airports.
Let's just get rid of all of these to clean this up and we'll do the same for.
This one as well, and let's get rid of.
This imports.
And we'll just do the same here at the top.
And let's go ahead and see if we can import all missing imports again, and that seems to have done
the job, so that's good.
So what we want to do in here is we want to get our interceptor to fetch our token from local storage,
and if we have a token, then we want it to automatically set.
The head is inside any request there's going to Apicella.
So that's exactly what we'll do.
Well, remove this through new error and will replace it and we'll say on this token equals local storage
doget item and we'll look for a token.
And then we'll say if we have the token.
What we want to do is take our request and effectively clone it, but in the clone, we're going to
set some headers and that's going to be the request we send up with our authorization token.
So we'll say Rick equals Rick Dot clone.
And inside here, what we'll do will say Saturday's.
And inside here, we can say authorization.
And we use our tactics and we'll say Barer again, be careful with the spelling here has to match.
Exactly.
And we have to leave this space as well.
Otherwise we will not be authorized and will pass up the token.
And this ad semicolons and remove any other warnings that it's related and we've still got a complaint
and of course, we need to return from this particular method.
So what we'll do is we'll say return and then we'll say next door, handle the request.
So this is going to take care of sending about OK, but we do need to provide this inside our app module
as well.
So this case while app module and what we'll do is we'll just come down to our other interceptors and
we'll copy the line and we'll change the third one and we'll use our JWT interceptor.
What this means is that we should now be able to go back to our app and we should have resolved our
particular problem we were having getting the delivery methods.
If we go back to the app and we seem to have got stuck.
But what we might need to do is since we've added something to our providers here is just to get ahead
of it, will just stop and restart our angular application.
My prediction is that that will not work until we do restart this app.
So once that's restarted, that's go across and refresh the page, which it seems to have done all by
itself.
And let's just refresh again.
And click on delivery, then we can see our delivery methods and we can select them, and we could certainly
do with some styling inside here.
And we'll come back to this because what we'll also need to do is deal with the shipping and handling
over here.
But what we'll do now, look, we've got things functional again.
We can now go ahead and refresh our application.
And if we take a look at what we're doing here when we go and get our delivery methods and go to our
headers, then what we should be able to see is that our authorization token was automatically sent
and was sent up with this particular request.
So what we'll take a look at next is we'll move on to our steps and we'll go to our review component
next and at the content inside here.