Complete the code to specify the HTTP method for full replacement using PUT.
fetch('/api/item/1', { method: '[1]' })
The PUT method is used to fully replace a resource at the specified URL.
Complete the code to send JSON data in a PUT request for full replacement.
fetch('/api/item/1', { method: 'PUT', headers: { 'Content-Type': '[1]' }, body: JSON.stringify({ name: 'New Item' }) })
When sending JSON data, the Content-Type header must be 'application/json'.
Fix the error in the PUT request code by completing the missing part.
fetch('/api/item/1', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: 1, [1] }) })
The body must include the full replacement data, such as the updated name.
Fill both blanks to create a full replacement PUT request with JSON data and proper headers.
fetch('/api/item/2', { method: '[1]', headers: { '[2]': 'application/json' }, body: JSON.stringify({ id: 2, name: 'Replaced Item' }) })
The method must be 'PUT' and the header key for JSON data is 'Content-Type'.
Fill all three blanks to complete the PUT request that fully replaces a resource with JSON data and logs the response status.
fetch('/api/item/3', { method: '[1]', headers: { '[2]': 'application/json' }, body: JSON.stringify({ id: 3, name: 'Complete Replacement' }) }) .then(response => console.log(response.[3]))
The method is 'PUT', the header key is 'Content-Type', and the response status is accessed via 'status'.