275. Changing the Response Body Type

Jul 21, 2026 06:09 · 3:16 · English · Whisper Turbo · 2 스피커
이 트랜스크립트는 다음에 만료됩니다. 7 며칠이요 영구 저장소 업그레이드 →
보이는 것만
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.

이 기록은 AI (자동 음성 인식)에 의해 생성되었습니다. 오류가 있을 수 있습니다 - 중요한 사용을 위해 원본 오디오와 확인하십시오. AI 정책

❤️ STT.ai가 마음에 드시나요? 친구들에게 알려주세요!
요약
요약 을 클릭하여 이 녹음의 AI 요약을 생성합니다.
요약...
이 녹음에 대해 AI에게 물어보기
이 녹음에 대해 질문하십시오 — AI는 관련 섹션을 찾아 답변합니다.