PUT method endpoints

The last method is PUT, and it is usually used to update a row in a database.

PUT /post/:slug

In Postman, you need to select the PUT method first, then the URL of the post you want to edit. Let's edit my-blog-post-3; so the URL will be http://localhost:3000/api/post/my-blog-post-3. In the Headers tab, you need to add, as in the POST method, the Content-Type header with the value application/x-www-form-urlencoded. The last part is the Body tab, where you can send the new data you want to replace, in this case, a new title and new content:

If everything works fine, you should get this response:

Again, if you want to verify the post was updated correctly, then go to the /posts endpoint in your browser:

As you can see, the post title, content, and slug were updated correctly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset