PUT, PATCH, DELETE in JavaScript

From the Fetch API cheat sheet · Basic Requests · verified Jul 2026

PUT, PATCH, DELETE

Updating and deleting resources with proper methods

javascript
// PUT - Full update
const response = await fetch(\`https://api.example.com/users/\${id}\`, {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Jane Doe',
    email: 'jane@example.com',
    age: 30
  })
})

// PATCH - Partial update
const response = await fetch(\`https://api.example.com/users/\${id}\`, {
  method: 'PATCH',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    email: 'newemail@example.com'
  })
})

// DELETE
const response = await fetch(\`https://api.example.com/users/\${id}\`, {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer token123'
  }
})

if (response.ok) {
  console.log('Resource deleted')
}
📌 PUT replaces entire resource, PATCH updates fields
🟢 DELETE typically returns 204 No Content on success
💡 Create a reusable API client for consistent requests
⚡ Handle empty responses appropriately (204, 205)

Continue with Fetch API

Save the full cheat sheet or work through every related task.

More JavaScript tasks

Back to the full Fetch API cheat sheet