In the last line " =" is showing the value of all the items and when I use only the "=" its showing only one item. Why is that?
axios.get("http://localhost:8000/tweets/api").then((result) => {
const list = result.data;
list.map((item) => {
const name = item.name;
const username = item.username;
const tweet = item.tweet;
const date = item.date;
const twitter = `<li><h2>${name} </h2> ${username} ${tweet} ${date} </li>`;
document.querySelector(".tweet").innerHTML = twitter;
});
});
}, []);
CodePudding user response:
= each time it appends the current twitter do the innerHTML each time but = it will affect the value to innerHTML so in that case it overrides the current value.
And at the end it will be the last item in the list
I recommend learning the basics and the syntax of javascript before jumping into coding in case if you don't know them i'm not trying to be rude sorry