I was making a simple todolist app and everything else works fine but my delete item code is only working in chrome and no other browser. I even tried it in latest firefox version but it just doesn't seem to work and I have no idea why.
Here's the code:
function removeTask(e) {
if (e.target.classList.contains("del")) {
//e.target.parentElement.remove();
let item = e.target.parentElement.childNodes[0].textContent
.replace(/[\n\r]+|[\s]{2,}/g, " ")
.trim();
console.log(item);
let url = `/items/${item}`;
http
.delete(url)
.then(reloader())
.catch((err) => console.log(err));
function reloader() {
location.reload();
}
}
}
The above code looks fine but whenever I try deleting an item, it works in chrome but is not working in firefox (latest version) and edge. I haven't checked on other browsers.
(Update: Sometimes it deletes an item but when I try deleting another item, it does not work)