Answers for "assigning headers with fetch"

4

javascript fetch headers

fetch('https://example.com/profile', {
  method: 'POST', // or 'PUT'
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});
Posted by: Guest on June-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language