278. Response Interceptors
Jul 21, 2026 06:00
· 2:46
· English
· Whisper Turbo
· 2 דוברים
תעתיק זה פג תוקף ב 7 ימים.
שדרוג לאחסון קבוע →
מציג בלבד
0:02
S…
Speaker 2 (278. Response Interceptors)
You're also not limited to interacting with the request in
0:06
S…
Speaker 2 (278. Response Interceptors)
an intersetter.
0:07
S…
Speaker 2 (278. Response Interceptors)
You can also interact with the response.
0:09
S…
Speaker 2 (278. Response Interceptors)
You do this by adding something here to handle because
0:13
S…
Speaker 2 (278. Response Interceptors)
handle actually gives you an observable,
0:16
S…
Speaker 2 (278. Response Interceptors)
which I guess makes sense because in the end,
0:19
S…
Speaker 2 (278. Response Interceptors)
your request is an observable to which you subscribe in the end.
0:22
S…
Speaker 2 (278. Response Interceptors)
So this in the end is the request with the response in
0:26
S…
Speaker 1 (278. Response Interceptors)
it, you could say,
0:27
S…
Speaker 2 (278. Response Interceptors)
wrapped into an observable.
0:29
S…
Speaker 2 (278. Response Interceptors)
And therefore here you can of course add pipe and do something
0:33
S…
Speaker 2 (278. Response Interceptors)
with the response if you want to.
0:35
S…
Speaker 2 (278. Response Interceptors)
You could add the map operator here to change the response.
0:39
S…
Speaker 2 (278. Response Interceptors)
For example,
0:39
S…
Speaker 2 (278. Response Interceptors)
of course you should be careful with that and not change it in a way that the rest of your application
0:44
S…
Speaker 1 (278. Response Interceptors)
breaks.
0:44
S…
Speaker 2 (278. Response Interceptors)
Or what I'll do here,
0:47
S…
Speaker 1 (278. Response Interceptors)
You use tab,
0:48
S…
Speaker 2 (278. Response Interceptors)
which you need to import from RxJS operators to simply
0:53
S…
Speaker 2 (278. Response Interceptors)
look into the response.
0:55
S…
Speaker 1 (278. Response Interceptors)
Now here in tab,
0:56
S…
Speaker 2 (278. Response Interceptors)
you get an event and that's important.
0:58
S…
Speaker 2 (278. Response Interceptors)
You always get events here.
1:00
S…
Speaker 2 (278. Response Interceptors)
Remember, I showed you that you can observe different kinds of responses
1:04
S…
Speaker 2 (278. Response Interceptors)
with the Angular HTTP client,
1:06
S…
Speaker 2 (278. Response Interceptors)
no matter what you chose there,
1:08
S…
Speaker 2 (278. Response Interceptors)
here in the intersetter,
1:10
S…
Speaker 2 (278. Response Interceptors)
you always get an event so that you have the most granular access
1:15
S…
Speaker 2 (278. Response Interceptors)
to the response you could possibly have.
1:17
S…
Speaker 1 (278. Response Interceptors)
So here,
1:18
S…
Speaker 2 (278. Response Interceptors)
for example, we could check if the event type
1:21
S…
Speaker 2 (278. Response Interceptors)
is equal to the HTTP event type,
1:24
S…
Speaker 2 (278. Response Interceptors)
which you also need to import,
1:25
S…
Speaker 2 (278. Response Interceptors)
of response,
1:28
S…
Speaker 2 (278. Response Interceptors)
because here maybe I only care about that response.
1:32
S…
Speaker 2 (278. Response Interceptors)
I will log the event before that,
1:36
S…
Speaker 2 (278. Response Interceptors)
however, so that we can see all events we got.
1:39
S…
Speaker 1 (278. Response Interceptors)
And then in here,
1:41
S…
Speaker 1 (278. Response Interceptors)
we could say response
1:45
S…
Speaker 1 (278. Response Interceptors)
arrived,
1:46
S…
Speaker 1 (278. Response Interceptors)
body data.
1:50
S…
Speaker 2 (278. Response Interceptors)
and then simply console .log the event body,
1:53
S…
Speaker 2 (278. Response Interceptors)
which here is the response body,
1:55
S…
Speaker 1 (278. Response Interceptors)
of course.
1:56
S…
Speaker 1 (278. Response Interceptors)
Now here again,
1:58
S…
Speaker 2 (278. Response Interceptors)
I'm just doing some logging,
1:59
S…
Speaker 2 (278. Response Interceptors)
but as I just mentioned,
2:00
S…
Speaker 2 (278. Response Interceptors)
you could use other operators like map here and even transform the response.
2:04
S…
Speaker 2 (278. Response Interceptors)
That would be possible.
2:05
S…
Speaker 2 (278. Response Interceptors)
So now if we save that and we go back and we have a look at the
2:09
S…
Speaker 2 (278. Response Interceptors)
console, we see a bunch of output there.
2:11
S…
Speaker 2 (278. Response Interceptors)
Let me clear it to make it a bit easier.
2:14
S…
Speaker 2 (278. Response Interceptors)
and fetch posts again.
2:15
S…
Speaker 2 (278. Response Interceptors)
And now you see request is on its way.
2:17
S…
Speaker 2 (278. Response Interceptors)
Then we have type zero,
2:18
S…
Speaker 1 (278. Response Interceptors)
which is this,
2:19
S…
Speaker 2 (278. Response Interceptors)
the request is now sent event.
2:21
S…
Speaker 2 (278. Response Interceptors)
Then we got the response.
2:22
S…
Speaker 1 (278. Response Interceptors)
Therefore,
2:23
S…
Speaker 2 (278. Response Interceptors)
we now got that response arrived log.
2:25
S…
Speaker 2 (278. Response Interceptors)
And there indeed,
2:26
S…
Speaker 2 (278. Response Interceptors)
we now see the response body being logged because that is what I'm doing here.
2:31
S…
Speaker 1 (278. Response Interceptors)
So this is possible too.
2:33
S…
Speaker 2 (278. Response Interceptors)
You cannot just interact with the request inside of your interest setter.
2:36
S…
Speaker 2 (278. Response Interceptors)
You can also interact with the response if you want to.
2:40
S…
Speaker 2 (278. Response Interceptors)
You can log it, you can manipulate it, whatever your requirements are.
תעתיק זה נוצר על ידי AI (הכרה אוטומטית של דיבור). ייתכן שיש בו שגיאות אשר מאשרות את השמע המקורי לשימוש קריטי. מדיניות AI
תקציר
לחץ לסכם כדי ליצור סיכום AI של תעתיק זה.
מסכם...
שאל את אל על התעתיק הזה.
שאל כל דבר על התמליל הזה, הבינה המלאכותית תמצא חלקים רלוונטיים ותענה.