On this page:
Delete a user: a tutorial
This tutorial should take you about 10 minutes to complete.
Before you begin
- Make sure you’ve set up your environment.
- Start the Orca Sightings service with
json-server.
How to delete a user
In this section, you’ll delete the user with an id of 4.
To use cURL:
- Open a new terminal window.
- Find the user you want to delete.
- Run the following command:
curl -X DELETE http://localhost:3000/users/4
To use Postman:
- In Postman’s main panel on the right, toward the top, select DELETE.
- Add the following content to the URL text box next to GET:
http://localhost:3000/users/4. - Click Send.
If you don’t specify a user ID, the service won’t delete all the users. Instead, it returns a 404 Not Found error message.
View the response
The response body should show an empty record:
{}
In Postman, you should also see a green 200 OK message at the top of the pane. Hover over that text to see the full confirmation message.
That’s it. Next, view the reference topic DELETE /users.
Also, you can try other tutorials or view other topics in the API reference.