I deleted my previous comment after reading the question again. The function you're using is correct, but I think you're using it in the wrong location. The
fetch()
function returns a
Promise<>
which is a fancy way of saying "this will produce something either now, or later on".
You've put your code for selecting the buttons
outside of the then() function, which means that it will probably execute
before the
Promise<>
has had chance to complete. You need to select the elements only once they've been appended to the HTML body:
document.querySelector('.movieList').appendChild(div)
const btns = document.querySelectorAll(".delete");
console.log(btns);
}
});