I have this error:
script.js:41 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'append') at script.js:41:12
in the below code
const form = document.querySelector("d-flex");
const glass = document.getElementById("glass");
const select = document.getElementById("episod-select");
const episodes = async () => {
// ? trying to bring the api to website and making a select tag for it
const res = await axios.get("https://api.tvmaze.com/shows/5/episodes");
return res;
};
const data = episodes().then((res) => {
console.log(res);
for (let i = 0; i < res.data.length; i++) {
const ses = res.data[i].season;
const epi = res.data[i].number;
const option = document.createElement("option");
option.innerText = `S0${ses}E0${epi}`;
select.append(option);
//! the error is right here ^^
}
});
Via Active questions tagged javascript - Stack Overflow https://ift.tt/Q2rpeIL
Comments
Post a Comment