In this video.
Let's finish up with the user API.
And what I left is about the deleting and going to be pretty simple to implement.
So inside the control edge, let's see how we are going to do that.
So down here, which is the delete, so we are going to find the user buy ID and then delete.
So here you go for this one, we can send the deleted user back to the client or we can send a static
test.
For example, user has been deleted or we can send an empty data.
So for this one, I don't want to have the deleted user being sent, so I'm going to await it and find
by ID and delete.
So here pass in the rec the user, meaning the log user and that is it.
So what is left is about what's sent the response back to the user, rest the status and pass in 200
minutes everything is okay and the JSON data and status.
And then we say a success.
And for the data we will say now.
Now empty.
Great.
And let's handle the error here by passing to our global error handler as error.
So here, let's pass in the next.
So I think for the update, we forgot to add the error down here.
So let's remove this one and now let's call next the pass in the entire error.
Or better still, we can call new and then our app error.
And here we pass in the entire error dot message.
And next is it pass in 500, meaning internal error.
So we can copy this one and place it inside all our controllers.
So think here we can change this one to this.
And then for the profile two, we can change this one to this.
And then for the log into, we can change this one to this.
And for the registration to we can change this one to this.
Perfect.
So I think we don't need a verification here and start.
And that is it.
So we are done with the entire user API creation.
So let's go ahead and then delete a user.
So back here, let's locate delete and for delete, I don't want to pass in the ID inside the URL.
So let's go ahead and then change the route.
So the users and users here for deleting, let's remove the ID here and let's remove the ID here and
let's save it.
And now let's check it out again.
We need to protect this endpoint.
So here as is logged in and comma separated.
So here delete.
I need to provide the token.
So let's go to the log in here.
And I have this user called Aram.
Now I have taken your token because I want to delete you.
So now here under delete, let's pass in here as a header and the authorization as that and bearer is
equal to that.
And let's remove this one and let me hit send.
And you can see success data is no.
So if I try to log in with that particular user or item, let's see the error.
Now let's have a look and you can see that invalid login credentials, meaning this user doesn't exist
anywhere in our database.
So guys here ends the API development for users.
If we lock something behind, definitely we come back and fix it.
Otherwise, the next video, let's work on the account API.