Fetch DELETE call

PHOTO EMBED

Wed Jun 22 2022 15:29:56 GMT+0000 (Coordinated Universal Time)

Saved by @zaccamp #javascript

fetch('https://reqres.in/api/users/2', {
    method: "DELETE",
    headers: {
        'Content-type': 'application/json'
    }
})
.then(res => {
    if (res.ok) { console.log("HTTP request successful") }
    else { console.log("HTTP request unsuccessful") }
    return res
})
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error))
content_copyCOPY

https://openjavascript.info/2022/01/03/using-fetch-to-make-get-post-put-and-delete-requests/