1fetch('https://example.com/delete', {
2 method: 'DELETE'
3})
4 .then(res => res.json())
5 .then(data => {
6 // Do some stuff...
7 })
8 .catch(err => console.log(err));
1return (
2 fetch(API_ROOT + route, {
3 method: 'POST',
4 crossDomain: true,
5 xhrFields: {
6 withCredentials: true
7 },
8 headers: {
9 Accept: 'application/json',
10 'Content-Type': 'application/json',
11 '_method': 'PATCH',
12 'Authorization': ''
13 },
14 data: JSON.stringify(data)
15 })
16 .then(res => res.json())
17 .then(res => {
18 console.log(res);
19 return res
20 })
21 .catch(err => console.error(err))
22 );
23