267. Sending a DELETE Request
Jul 21, 2026 05:59
· 3:27
· English
· Whisper Turbo
· 2 Овозли эшиттиришлар
Бу транскрипт муддати тугайди 7 кунлар.
Доимий сақлаш учун янгилаш →
Фақат кўрсатиш
0:01
S…
Speaker 1 (267. Sending a DELETE Request)
Now that we had a look at how we can send requests,
0:05
S…
Speaker 1 (267. Sending a DELETE Request)
how we can post data,
0:06
S…
Speaker 1 (267. Sending a DELETE Request)
how we can get data,
0:07
S…
Speaker 1 (267. Sending a DELETE Request)
let's finish this basic request sending up by making
0:11
S…
Speaker 1 (267. Sending a DELETE Request)
sure that we can also clear our posts so that we can delete data.
0:15
S…
Speaker 2 (267. Sending a DELETE Request)
And for that,
0:17
S…
Speaker 1 (267. Sending a DELETE Request)
of course, definitely feel free to pause this video and try it on your own first.
0:21
S…
Speaker 1 (267. Sending a DELETE Request)
Try making sure that whenever this onClearPosts method runs,
0:25
S…
Speaker 1 (267. Sending a DELETE Request)
which will happen when we click that ClearPosts button up
0:29
S…
Speaker 1 (267. Sending a DELETE Request)
there,
0:30
S…
Speaker 1 (267. Sending a DELETE Request)
that whenever this method runs that you send a request that deletes
0:34
S…
Speaker 1 (267. Sending a DELETE Request)
all the posts on the backend.
0:36
S…
Speaker 2 (267. Sending a DELETE Request)
You learned everything you need for that,
0:38
S…
Speaker 1 (267. Sending a DELETE Request)
so here's your chance to pause the video and try it on your own.
0:43
S…
Speaker 1 (267. Sending a DELETE Request)
Were you successful?
0:44
S…
Speaker 1 (267. Sending a DELETE Request)
Well,
0:45
S…
Speaker 2 (267. Sending a DELETE Request)
it's not that hard.
0:46
S…
Speaker 1 (267. Sending a DELETE Request)
It's almost the same type of request we sent before.
0:50
S…
Speaker 1 (267. Sending a DELETE Request)
Now let's keep the structure of sending the requests in
0:54
S…
Speaker 1 (267. Sending a DELETE Request)
the posts service.
0:56
S…
Speaker 2 (267. Sending a DELETE Request)
So in there,
0:57
S…
Speaker 2 (267. Sending a DELETE Request)
I will add a new method,
0:58
S…
Speaker 1 (267. Sending a DELETE Request)
which I'll name delete posts.
1:00
S…
Speaker 1 (267. Sending a DELETE Request)
Of course,
1:01
S…
Speaker 1 (267. Sending a DELETE Request)
you can name it also clear posts or whatever you want.
1:04
S…
Speaker 2 (267. Sending a DELETE Request)
Now in there,
1:05
S…
Speaker 1 (267. Sending a DELETE Request)
I will use the HTTP client because that is
1:09
S…
Speaker 1 (267. Sending a DELETE Request)
our central client for all HTTP requests you wanna send from
1:13
S…
Speaker 2 (267. Sending a DELETE Request)
inside our Angular app.
1:14
S…
Speaker 2 (267. Sending a DELETE Request)
And there,
1:15
S…
Speaker 1 (267. Sending a DELETE Request)
we can now use the delete method,
1:18
S…
Speaker 1 (267. Sending a DELETE Request)
which will send a,
1:19
S…
Speaker 1 (267. Sending a DELETE Request)
well, delete request.
1:21
S…
Speaker 1 (267. Sending a DELETE Request)
Now this method requires a URL to which it should send the request
1:25
S…
Speaker 1 (267. Sending a DELETE Request)
and since I want to clear all posts,
1:27
S…
Speaker 1 (267. Sending a DELETE Request)
I will grab this URL which targets the overall posts
1:31
S…
Speaker 1 (267. Sending a DELETE Request)
node and send my request there so that all the posts
1:35
S…
Speaker 1 (267. Sending a DELETE Request)
there get deleted.
1:38
S…
Speaker 1 (267. Sending a DELETE Request)
Now, if I wanna be informed about that deletion process in the component,
1:42
S…
Speaker 1 (267. Sending a DELETE Request)
which in this case I want,
1:44
S…
Speaker 1 (267. Sending a DELETE Request)
but if you chose a different solution,
1:45
S…
Speaker 1 (267. Sending a DELETE Request)
that's fine too.
1:46
S…
Speaker 1 (267. Sending a DELETE Request)
But if I want to be informed in a component,
1:49
S…
Speaker 1 (267. Sending a DELETE Request)
I will return my observable here and I will not subscribe here
1:53
S…
Speaker 1 (267. Sending a DELETE Request)
in the service,
1:54
S…
Speaker 1 (267. Sending a DELETE Request)
but instead now in the app component in onClearPosts,
1:58
S…
Speaker 1 (267. Sending a DELETE Request)
I can reach out to the posts service and call DeletePosts.
2:02
S…
Speaker 1 (267. Sending a DELETE Request)
And since this returns an observable,
2:04
S…
Speaker 1 (267. Sending a DELETE Request)
we now have to subscribe here.
2:06
S…
Speaker 1 (267. Sending a DELETE Request)
Now, why do I want to subscribe here?
2:08
S…
Speaker 2 (267. Sending a DELETE Request)
Well,
2:09
S…
Speaker 1 (267. Sending a DELETE Request)
if I deleted all posts,
2:10
S…
Speaker 1 (267. Sending a DELETE Request)
I also want to clear my loaded posts array here in the component.
2:14
S…
Speaker 1 (267. Sending a DELETE Request)
So I will add a method here where I don't really care about the
2:19
S…
Speaker 1 (267. Sending a DELETE Request)
result of our request or of the response,
2:22
S…
Speaker 1 (267. Sending a DELETE Request)
but I know that this function here will only run if it succeeded.
2:25
S…
Speaker 2 (267. Sending a DELETE Request)
And therefore here,
2:27
S…
Speaker 1 (267. Sending a DELETE Request)
I will then simply just set this loaded posts
2:31
S…
Speaker 1 (267. Sending a DELETE Request)
equal to an empty array again to reset it.
2:34
S…
Speaker 1 (267. Sending a DELETE Request)
And with these changes to the service and to the component,
2:37
S…
Speaker 1 (267. Sending a DELETE Request)
if we go back to our application and we let this reload,
2:41
S…
Speaker 1 (267. Sending a DELETE Request)
if I click clear posts,
2:42
S…
Speaker 1 (267. Sending a DELETE Request)
you see eventually it gets rid of all the posts and on Firebase,
2:46
S…
Speaker 1 (267. Sending a DELETE Request)
we also see that this posts node does not exist anymore.
2:49
S…
Speaker 1 (267. Sending a DELETE Request)
And of course,
2:50
S…
Speaker 1 (267. Sending a DELETE Request)
we can still add new posts here.
2:55
S…
Speaker 1 (267. Sending a DELETE Request)
So all our old functionality still is there.
2:58
S…
Speaker 2 (267. Sending a DELETE Request)
The only thing we have,
2:59
S…
Speaker 1 (267. Sending a DELETE Request)
of course, is that currently we got no logic to automatically update our
3:03
S…
Speaker 1 (267. Sending a DELETE Request)
list down there once we added a new post.
3:06
S…
Speaker 1 (267. Sending a DELETE Request)
Now you can definitely score some bonus point if you implement this.
3:09
S…
Speaker 1 (267. Sending a DELETE Request)
I'll not do it here because it's not really related to the fetching of data,
3:13
S…
Speaker 1 (267. Sending a DELETE Request)
just to how you react to the sending of a post being done.
3:17
S…
Speaker 2 (267. Sending a DELETE Request)
So with that,
3:18
S…
Speaker 1 (267. Sending a DELETE Request)
we had a thorough look at different kinds of requests we can send.
3:22
S…
Speaker 1 (267. Sending a DELETE Request)
Now, what if something goes wrong?
Бу транскрипт AI (автомат сўзлашувни таниб олиш) томонидан яратилган. Хатолар бўлиши мумкин - муҳим фойдаланиш учун оригинал аудио билан текширинг. AI сиёсати
Тақриз
Ушбу транскриптнинг AI резюмесини яратиш учун "Тафсиллаш" тугмасини босинг.
Тақсимланмоқда...
Бу транскрипт ҳақида AIдан сўранг
Ушбу транскрипт ҳақида бирор нарса сўранг — AI тегишли қисмларни топиб жавоб беради.