PATCH request for updating data in the database

PHOTO EMBED

Sun May 16 2021 06:18:02 GMT+0000 (Coordinated Universal Time)

Saved by @jatin_sachdeva #javascript

fetch("http://www.example.com/books/1", { // note we are going to /1
  method: "PATCH",
  headers: {
      "Content-Type" : "application/json"
    },
  body: JSON.stringify(
    {
      "likes": 5           // we are changing the "likes" value to 5
    }
  )
});
content_copyCOPY

https://blog.devgenius.io/using-fetch-to-update-the-database-and-dom-without-refreshing-the-page-3f05c343166b