K
K
kachurinets2018-03-16 21:46:14
JavaScript
kachurinets, 2018-03-16 21:46:14

How to check for the presence of a token?

I'm doing spa on angular 4. The bottom line is that I have an authorization token stored in my localstorage. I have a menu component where I need to show the Login or Logout button in a certain state. As I understand it, I need to check the presence of a token in the storage through the component. Tell me how to implement it, I would like to see the implementation of such a thing. Perhaps someone has an example of such a check.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devalone, 2018-03-16
@kachurinets

I made a service for the API and it monitors this
https://github.com/DevAlone/learn_these_fucking_wo...
the menu changes depending on the condition here
https://github.com/DevAlone/learn_these_fucking_wo...
It does not pull the storage every times, because it will be slow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question