In Angular, we have the opportunity to add HTTP interceptors. The HTTP interceptor is exactly what it’s named – essentially an interceptor that intercepts each HTTP call. This means that you for instance could add an HTTP token to all the API calls that are being made. This is very trivial when you have for instance JWT authorization. In that case, you would want to add the token to each and every API call. This would make it much easier than adding it manually on all API calls, and it would automate a lot of stuff. Another case would be to actually intercept the STATUS code from the API. For instance, if you get a 401 Unauthorized, you could “log-out” the user if the token is required, OR, you could force the user to sign in once again on the page.
#Angular #Interceptors #JavaScript #FrontEnd #HttpInterceptor #typescript
My website:
https://devbyseb.com/
OpenBrewery API:
https://api.openbrewerydb.org/breweri...
Смотрите видео Angular Interceptors - HTTP Interceptors онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Sebastian Persson 01 Январь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,790 раз и оно понравилось 32 людям.