{"id":2321,"date":"2025-06-18T14:50:00","date_gmt":"2025-06-18T21:50:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=2321"},"modified":"2025-06-18T14:50:01","modified_gmt":"2025-06-18T21:50:01","slug":"http-interceptors-in-angular-using-functions","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/http-interceptors-in-angular-using-functions\/","title":{"rendered":"HTTP interceptors in Angular, using functions"},"content":{"rendered":"\n<p>In the past few years, Angular has started replacing some class-based features, such as <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/route-guards-canactivate-canactivatechild-candeactivate\/\" target=\"_blank\" rel=\"noopener\" title=\"\">guards<\/a> and interceptors, with new function-based syntaxes.<\/p>\n\n\n\n<p>What&#8217;s interesting about interceptors is that the old, <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/how-to-use-http-interceptors\/\" target=\"_blank\" rel=\"noopener\" title=\"\">dependency injection-based approach<\/a> is not deprecated and remains valid, though it&#8217;s a bit more verbose and less convenient.<\/p>\n\n\n\n<p>That said, I just updated this 2019 tutorial of mine to cover <a href=\"https:\/\/blog.angulartraining.com\/http-interceptors-in-angular-61dcf80b6bdd\" target=\"_blank\" rel=\"noopener\" title=\"\">function-based interceptors<\/a> instead:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2025\/06\/Screenshot-2025-06-18-at-2.25.06\u202fPM-1024x539.png\" alt=\"\" class=\"wp-image-2322\" style=\"width:650px;height:auto\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2025\/06\/Screenshot-2025-06-18-at-2.25.06\u202fPM-1024x539.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2025\/06\/Screenshot-2025-06-18-at-2.25.06\u202fPM-300x158.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2025\/06\/Screenshot-2025-06-18-at-2.25.06\u202fPM-768x404.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2025\/06\/Screenshot-2025-06-18-at-2.25.06\u202fPM.png 1292w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>The updated <a href=\"https:\/\/blog.angulartraining.com\/http-interceptors-in-angular-61dcf80b6bdd\" target=\"_blank\" rel=\"noopener\" title=\"\">tutorial<\/a> includes examples for intercepting both HTTP requests and responses.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past few years, Angular has started replacing some class-based features, such as guards and interceptors, with new function-based syntaxes. What&#8217;s interesting about interceptors is that the old, dependency injection-based approach is not deprecated and remains valid, though it&#8217;s a bit more verbose and less convenient. That said, I just updated this 2019 tutorial [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,21,32],"tags":[],"class_list":["post-2321","post","type-post","status-publish","format-standard","hentry","category-angular","category-architecture","category-http"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/2321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=2321"}],"version-history":[{"count":1,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/2321\/revisions"}],"predecessor-version":[{"id":2323,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/2321\/revisions\/2323"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=2321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=2321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=2321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}