PUT replaces/updates a resource at a URL (send JSON body). DELETE asks the server to remove it (often no body). Set method in the fetch init object. JSONPlaceholder fakes both.

Results appear here.

Update or delete a post by id.

Important JavaScript

await fetch(url + "/" + id, {
  method: "PUT",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ id: id, title: "…", body: "…", userId: 1 })
});

await fetch(url + "/" + id, { method: "DELETE" });