Answers for "Fetch patch method"

4

js fetch delete

fetch('https://example.com/delete', {
  method: 'DELETE'
})
  .then(res => res.json())
  .then(data => {
    // Do some stuff...
  })
  .catch(err => console.log(err));
Posted by: Guest on July-14-2020
0

Fetch patch method

return (
        fetch(API_ROOT + route, {
            method: 'POST',
            crossDomain: true,
            xhrFields: {
                withCredentials: true
            },
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
                '_method': 'PATCH',
                'Authorization': ''
            },
            data: JSON.stringify(data)
        })
        .then(res => res.json())
        .then(res => {
            console.log(res);
            return res
        })
        .catch(err => console.error(err))
    );
Posted by: Guest on August-31-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language