DELETE /reviews/:id

This will delete all the reviews of the book with the ID provided, or only the ones written by a specific user for that book

Endpoint URL

http://127.0.0.1:8080/api/reviews/:id

Path parameters

Name
Type
Description

id

integer

Unique identifier for each review

Example code

delete.addEventListener("click", async () => {
    // Ask if the user is sure they want to delete the review
    const confirmDelete = window.confirm("Are you sure you want to delete this review?");

    // If the user clicked OK, delete the review
    if (confirmDelete) {
        try {
            const response = await fetch(`/api/reviews/${review.id}`, {
                method: "DELETE",
                headers: {
                    "Content-Type": "application/json",
                },
            });

            if (!response.ok) {
                throw new Error(`HTTP error! status: ${response.status}`);
            } else {
                const data = await response.json();
                console.log("Success:", data.message);
            }
        } catch (error) {
            console.error("Error:", error);
        }
    }
});

Example response

Response fields

Name
Type
Description

message

string

A message to confirm or post an error, status of the POST request

Last updated