Day 23 of 100days of code.

Day 23 of 100days of code.

ยท

1 min read

Fundamentals of node JS

Handling DELETE Request

Lets create a new route handler for handling the DELETE request on the HTTP server. Lets write some logic. first we want to get the ID of the movie using the find() method, then we get the index of the movie using the indexOf() method, Then we use the splice() method to remove or delete the movie from our movies array๐Ÿ‘‡๐Ÿผ

Lets see the server response๐Ÿ‘‡๐Ÿผ

The movie was also removed or deleted from our movies.json file๐Ÿ‘‡๐Ÿผ

Lets refactor the code base for cleaner code. ๐Ÿ‘‡๐Ÿผ

We can also refactor the endpoints as well from this ๐Ÿ‘‡๐Ÿผ

To this ๐Ÿ‘‡๐Ÿผusing the route() method chaining the different HTTP method using the endpoint.

That's all for this lesson.

Next: Understanding Middleware

See you soon๐Ÿ˜Š๐ŸซกโœŒ๐Ÿผ...

ย