fetch patch request javascript code example

Example 1: js fetch delete

fetch('https://example.com/delete', {
  method: 'DELETE'
})
  .then(res => res.json())
  .then(data => {
    // Do some stuff...
  })
  .catch(err => console.log(err));

Example 2: fetch api template

//fetch api template
const fetchData=(inputs)=>{
fetch('https://example.com/api', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(inputs)
  })
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    ChromeSamples.log(data.whatever);
  });
}