Updated on Sep 14, 2023

1

min read

Delete an actor

DELETE

You can remove an actor from the Movies database using the Movies API. This document provides instructions on how to make a DELETE request to delete an actor entry.

Endpoint

To delete an actor, make a DELETE request to the following endpoint:

DELETE /actors/{actor_id}

Replace {actor_id} with the unique identifier of the actor you want to delete.

Request

Here's an example of how to make a DELETE request to delete an actor using JavaScript:

const actorId = 789; // Replace with the actual actor ID
const apiUrl = `https://api.moviesapi.com/v1/actors/${actorId}`;

fetch(apiUrl, {
  method: "DELETE"
})
  .then(response => {
    if (response.status === 204) {
      console.log("Actor Deleted Successfully.");
    } else {
      console.error("Error:", response.status);
    }
  })
  .catch(error => {
    console.error("Error:", error);
  });

In this example, we use the fetch function to make an HTTP DELETE request to the specified API endpoint. Replace 789 with the actual actor ID you want to delete.

Response

Upon successful deletion, the API will respond with a status code of 204 No Content, indicating that the actor has been successfully removed from the database.

You have now learned how to delete an actor entry from the Movies database using the API. Keep in mind that this action is irreversible, so use it with caution.