-1

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?

  • Hi Gustas, I dont know details but it looks like you need to use local storage. Firstly set your item into local storage and then get it in the interceptor. take a look: https://blog.jscrambler.com/working-with-angular-local-storage/ – AbdurrahmanY Oct 21 '22 at 14:15
  • Thanks for the reply! the local storage worked. Right now I'm trying to implement a service to grab the value so I can use it everywhere in my application. – GustaMan9000 Oct 21 '22 at 22:33
  • you are welcome. turned it to an answer. Just check if it is work for you. – AbdurrahmanY Oct 22 '22 at 08:41

1 Answers1

0

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

AbdurrahmanY
  • 809
  • 13
  • 22