275. Changing the Response Body Type
Jul 21, 2026 06:09
· 3:16
· English
· Whisper Turbo
· 2 Hangszórók
Ez az átirat lejár: 7 napokat.
Az állandó tárolásra vonatkozó korszerűsítés →
Csak megjelenítése
0:02
S…
Speaker 2 (275. Changing the Response Body Type)
You can not only configure the observe mode
0:06
S…
Speaker 2 (275. Changing the Response Body Type)
here, you can also configure the response type.
0:10
S…
Speaker 2 (275. Changing the Response Body Type)
The default here is JSON,
0:12
S…
Speaker 2 (275. Changing the Response Body Type)
which means the response data,
0:14
S…
Speaker 2 (275. Changing the Response Body Type)
so the data in the body of your response is JSON,
0:17
S…
Speaker 2 (275. Changing the Response Body Type)
and that tells Angular that it should automatically parse it and convert
0:21
S…
Speaker 2 (275. Changing the Response Body Type)
it to a JavaScript object.
0:22
S…
Speaker 1 (275. Changing the Response Body Type)
You could,
0:23
S…
Speaker 2 (275. Changing the Response Body Type)
however, also tell Angular,
0:25
S…
Speaker 2 (275. Changing the Response Body Type)
the response type will be text,
0:26
S…
Speaker 2 (275. Changing the Response Body Type)
and please keep it as text,
0:28
S…
Speaker 2 (275. Changing the Response Body Type)
don't try to convert it to a JavaScript object.
0:30
S…
Speaker 2 (275. Changing the Response Body Type)
It could also be a blob if it is a file,
0:33
S…
Speaker 2 (275. Changing the Response Body Type)
for example.
0:34
S…
Speaker 2 (275. Changing the Response Body Type)
The official docs,
0:35
S…
Speaker 1 (275. Changing the Response Body Type)
of course,
0:36
S…
Speaker 2 (275. Changing the Response Body Type)
are the place where you can learn all about all available response types.
0:40
S…
Speaker 2 (275. Changing the Response Body Type)
So if we use text here and I add a new post here,
0:44
S…
Speaker 1 (275. Changing the Response Body Type)
oops,
0:45
S…
Speaker 2 (275. Changing the Response Body Type)
send it first,
0:47
S…
Speaker 1 (275. Changing the Response Body Type)
then you still see,
0:49
S…
Speaker 2 (275. Changing the Response Body Type)
of course, that I get null here because we had null before.
0:52
S…
Speaker 2 (275. Changing the Response Body Type)
And even if this is interpreted as a text,
0:54
S…
Speaker 2 (275. Changing the Response Body Type)
it still prints null.
0:56
S…
Speaker 2 (275. Changing the Response Body Type)
However, you can clearly see it is treated as a text because it
1:00
S…
Speaker 2 (275. Changing the Response Body Type)
is now wrapped in quotation marks before it was treated as the null
1:04
S…
Speaker 2 (275. Changing the Response Body Type)
object that exists in JavaScript.
1:06
S…
Speaker 2 (275. Changing the Response Body Type)
It becomes even clearer if we try using that here when
1:10
S…
Speaker 2 (275. Changing the Response Body Type)
we get posts.
1:11
S…
Speaker 1 (275. Changing the Response Body Type)
There,
1:12
S…
Speaker 2 (275. Changing the Response Body Type)
if I switch the response type to text,
1:14
S…
Speaker 2 (275. Changing the Response Body Type)
we'll see that our application even breaks because it won't work if
1:19
S…
Speaker 2 (275. Changing the Response Body Type)
we try to work with a text response.
1:22
S…
Speaker 2 (275. Changing the Response Body Type)
and i even get an error here because i am using that generic assignment
1:26
S…
Speaker 2 (275. Changing the Response Body Type)
here and i'm saying hey the data that is returned here is actually
1:30
S…
Speaker 2 (275. Changing the Response Body Type)
of type javascript object that in the end holds a nested post well
1:34
S…
Speaker 2 (275. Changing the Response Body Type)
typescript is smart and detects well if you tell me that
1:38
S…
Speaker 2 (275. Changing the Response Body Type)
my response data will be of that format then it needs to be convertible
1:43
S…
Speaker 2 (275. Changing the Response Body Type)
to a javascript object if you then also tell me
1:46
S…
Speaker 2 (275. Changing the Response Body Type)
that the response type down there is text,
1:48
S…
Speaker 2 (275. Changing the Response Body Type)
then you have to be lying somewhere because it can't be both.
1:51
S…
Speaker 2 (275. Changing the Response Body Type)
It can't be a string,
1:53
S…
Speaker 2 (275. Changing the Response Body Type)
which is simply not in that format and
1:57
S…
Speaker 2 (275. Changing the Response Body Type)
such a JavaScript object at the same time.
1:59
S…
Speaker 2 (275. Changing the Response Body Type)
So to make this work,
2:01
S…
Speaker 2 (275. Changing the Response Body Type)
we would have to get rid of that generic type assignment.
2:03
S…
Speaker 2 (275. Changing the Response Body Type)
And now we are allowed to save this.
2:06
S…
Speaker 2 (275. Changing the Response Body Type)
And now of course you see this breaks here.
2:09
S…
Speaker 2 (275. Changing the Response Body Type)
If I
2:11
S…
Speaker 2 (275. Changing the Response Body Type)
Try sending a post and I fetch my post it breaks and I just see these lines
2:15
S…
Speaker 2 (275. Changing the Response Body Type)
because my response here is in the end now treated
2:19
S…
Speaker 2 (275. Changing the Response Body Type)
as a text and not as a
2:23
S…
Speaker 2 (275. Changing the Response Body Type)
JavaScript object
2:25
S…
Speaker 2 (275. Changing the Response Body Type)
And actually here it even breaks because the way I try to handle this is not
2:29
S…
Speaker 1 (275. Changing the Response Body Type)
correct.
2:30
S…
Speaker 2 (275. Changing the Response Body Type)
So I will revert this and I will revert this back
2:34
S…
Speaker 2 (275. Changing the Response Body Type)
to JSON, which is the correct data type,
2:36
S…
Speaker 2 (275. Changing the Response Body Type)
which now works.
2:37
S…
Speaker 2 (275. Changing the Response Body Type)
But it is important to also be aware of this option,
2:41
S…
Speaker 2 (275. Changing the Response Body Type)
which you can use.
2:43
S…
Speaker 2 (275. Changing the Response Body Type)
to tell angular in case you are really getting back some text and you don't
2:47
S…
Speaker 2 (275. Changing the Response Body Type)
want angular to parse it to a javascript object or maybe you are
2:51
S…
Speaker 2 (275. Changing the Response Body Type)
getting back json but you still don't want to let angular parse it because you
2:55
S…
Speaker 2 (275. Changing the Response Body Type)
want to parse it on your own at a later point of time or anything like that for
3:00
S…
Speaker 2 (275. Changing the Response Body Type)
this you can set the response type the default is json
3:04
S…
Speaker 2 (275. Changing the Response Body Type)
and most of the time like in probably 99 of all cases
3:08
S…
Speaker 2 (275. Changing the Response Body Type)
this is the type you want to keep
3:11
S…
Speaker 2 (275. Changing the Response Body Type)
So typically, you don't need to overwrite that.
Ezt az átiratot az MI (automatikus beszédfelismerés) generálta. Hibaüzeneteket tartalmazhat • ellenõrizze az eredeti audiót kritikus használat esetén. AI-politika
Összefoglaló
Kattintson a Summarize gombra, hogy létrehozzon egy AI összefoglalót erről az átiratról.
Összefoglaló...
Kérdezd meg AI-t erről a Transcriptről
Kérdezzen bármit erről az átiratról Az MI megtalálja a megfelelő szakaszokat és választ.