How can I return the response.ok and then make the console.log() and the window.location? is this a case that I should use another then?
function deleteSomething() {
fetch(`https.api/delete.xyz`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
})
.then(function (response) {
if (response.ok) {
return response.ok
console.log("deleted!")
window.location.href = `freecodecamp.org`
} else {
return Promise.reject(response)
}
})
.catch(function (err) {
console.log("There is an error", err)
});
}
deleteSomething()