PUT Request to REST API

Learn to send a PUT request to the REST API to edit a lecture post.

In the previous lesson, we saw how to send a PUT request using fetch API. In this lesson, we will refine that request to edit the note on the frontend on the fly. But first, let’s implement the functionality for the Cancel button.

Event listener for Cancel button

If the user clicks the Cancel button, it should add the read-only attribute back to the title and the body content of the lecture note.

With the Excellence folder open in VS Code, access the terminal by clicking the "View" option and choosing "Terminal." Run the start script using the npm run start command. The start script will watch for any changes in the code and recompile it.

In the constructor, select all Cancel buttons on the Lecture Notes page in a Nodelist called cancelButtons using the cancel-btn class as follows:

Get hands-on with 1400+ tech skills courses.