1
00:00:07,450 --> 00:00:08,500
In this video.

2
00:00:08,500 --> 00:00:11,470
Let's finish up with the user API.

3
00:00:11,470 --> 00:00:16,870
And what I left is about the deleting and going to be pretty simple to implement.

4
00:00:16,870 --> 00:00:21,250
So inside the control edge, let's see how we are going to do that.

5
00:00:21,370 --> 00:00:28,870
So down here, which is the delete, so we are going to find the user buy ID and then delete.

6
00:00:28,870 --> 00:00:37,570
So here you go for this one, we can send the deleted user back to the client or we can send a static

7
00:00:37,570 --> 00:00:37,900
test.

8
00:00:37,900 --> 00:00:43,630
For example, user has been deleted or we can send an empty data.

9
00:00:43,630 --> 00:00:51,040
So for this one, I don't want to have the deleted user being sent, so I'm going to await it and find

10
00:00:51,050 --> 00:00:53,770
by ID and delete.

11
00:00:53,770 --> 00:01:00,610
So here pass in the rec the user, meaning the log user and that is it.

12
00:01:00,610 --> 00:01:08,810
So what is left is about what's sent the response back to the user, rest the status and pass in 200

13
00:01:08,810 --> 00:01:14,050
minutes everything is okay and the JSON data and status.

14
00:01:14,050 --> 00:01:17,320
And then we say a success.

15
00:01:17,320 --> 00:01:20,590
And for the data we will say now.

16
00:01:22,300 --> 00:01:23,470
Now empty.

17
00:01:24,580 --> 00:01:25,150
Great.

18
00:01:25,300 --> 00:01:32,230
And let's handle the error here by passing to our global error handler as error.

19
00:01:32,290 --> 00:01:34,840
So here, let's pass in the next.

20
00:01:34,840 --> 00:01:39,530
So I think for the update, we forgot to add the error down here.

21
00:01:39,550 --> 00:01:45,010
So let's remove this one and now let's call next the pass in the entire error.

22
00:01:45,190 --> 00:01:49,660
Or better still, we can call new and then our app error.

23
00:01:49,750 --> 00:01:54,370
And here we pass in the entire error dot message.

24
00:01:54,430 --> 00:01:59,410
And next is it pass in 500, meaning internal error.

25
00:01:59,440 --> 00:02:04,380
So we can copy this one and place it inside all our controllers.

26
00:02:04,390 --> 00:02:08,620
So think here we can change this one to this.

27
00:02:09,070 --> 00:02:13,630
And then for the profile two, we can change this one to this.

28
00:02:13,810 --> 00:02:17,890
And then for the log into, we can change this one to this.

29
00:02:18,280 --> 00:02:24,120
And for the registration to we can change this one to this.

30
00:02:24,130 --> 00:02:24,790
Perfect.

31
00:02:24,790 --> 00:02:28,930
So I think we don't need a verification here and start.

32
00:02:29,020 --> 00:02:30,220
And that is it.

33
00:02:30,220 --> 00:02:33,830
So we are done with the entire user API creation.

34
00:02:33,850 --> 00:02:36,320
So let's go ahead and then delete a user.

35
00:02:36,340 --> 00:02:43,480
So back here, let's locate delete and for delete, I don't want to pass in the ID inside the URL.

36
00:02:43,510 --> 00:02:47,100
So let's go ahead and then change the route.

37
00:02:47,110 --> 00:02:56,230
So the users and users here for deleting, let's remove the ID here and let's remove the ID here and

38
00:02:56,230 --> 00:02:57,010
let's save it.

39
00:02:57,010 --> 00:02:59,730
And now let's check it out again.

40
00:02:59,740 --> 00:03:01,870
We need to protect this endpoint.

41
00:03:01,870 --> 00:03:07,710
So here as is logged in and comma separated.

42
00:03:07,720 --> 00:03:09,370
So here delete.

43
00:03:09,370 --> 00:03:11,240
I need to provide the token.

44
00:03:11,260 --> 00:03:13,450
So let's go to the log in here.

45
00:03:13,450 --> 00:03:15,790
And I have this user called Aram.

46
00:03:15,910 --> 00:03:20,030
Now I have taken your token because I want to delete you.

47
00:03:20,050 --> 00:03:31,810
So now here under delete, let's pass in here as a header and the authorization as that and bearer is

48
00:03:31,810 --> 00:03:32,950
equal to that.

49
00:03:32,950 --> 00:03:36,250
And let's remove this one and let me hit send.

50
00:03:36,910 --> 00:03:40,030
And you can see success data is no.

51
00:03:40,060 --> 00:03:46,000
So if I try to log in with that particular user or item, let's see the error.

52
00:03:46,390 --> 00:03:54,490
Now let's have a look and you can see that invalid login credentials, meaning this user doesn't exist

53
00:03:54,490 --> 00:03:56,610
anywhere in our database.

54
00:03:56,620 --> 00:04:00,610
So guys here ends the API development for users.

55
00:04:00,700 --> 00:04:04,870
If we lock something behind, definitely we come back and fix it.

56
00:04:04,900 --> 00:04:09,580
Otherwise, the next video, let's work on the account API.

