Implementing an endpoint to delete a note using the HTTP verb DELETE
To delete Note
, we will implement the endpoint that meets specific requirements. Let's make a list of these requirements to gain an understanding of what the request and response should look like.
The request is expected to meet the following criteria:
- The HTTP method will be
DELETE
. - The HTTP route will be
/notes/:id
. - The resource URL will have the
id
of theNote
that we are trying to delete.
The response is expected to meet the following criteria:
- Delete the
Note
from the database using the built-inorm
-based syntax whoseid
is the same as theid
argument that is present in the resource URL. - After processing the delete request, the following will occur:
- The status code will show
204, No Content
. - The response body will be empty.
- The
Content-Type
response header will be set toapplication/json
.
- The status code will show
With this information, we will go ahead and define the route to delete Note...