Skip to main content

Command Palette

Search for a command to run...

Day 23 of 100days of code.

Published
โ€ข1 min readโ€ขView as Markdown
Day 23 of 100days of code.
P

๐Ÿ‘‹ Hi there! I'm Promise, a passionate MERN Stack Software Developer with a knack for turning ideas into captivating digital experiences. I specialise in creating responsive and user-friendly interfaces that not only meet but exceed the expectations of clients.

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๐Ÿ˜Š๐ŸซกโœŒ๐Ÿผ...

F

I recommend you share the codes as snippets instead of images so we can easily copy-paste them.

For more information about code snippets, you can refer to Hashnode Markdown Guide and Neptun Editor Guide.

1
P
Paks2y ago

Thank you ๐Ÿ™๐Ÿฝ

More from this blog

Untitled Publication

36 posts