Is there a way to pass a value into an Interceptor class?


For background: I have an interceptor that clones a request and inserts a bearer token, I want to add another field to this newRequest called: id with a value I grabbed from an eventEmitter in another class: AppComponent

I have value but I can’t pass it to the interceptor like I would to a component via html. Is there a way to do this?


I don’t know details but it looks like you need to use localStorage or sessionStorage

Firstly set your item into local/session storage and then get it, in the interceptor.
Please just consider for security precautions and search for which storage type is proper for you.

take a look:
working-with-angular-local-storage and storage types in angular

Answered By – AbdurrahmanY

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published