This part of code only shows the first and second person in the database "Ban" status.
console.log("Banned0",res.data.data[0].banned); //display the first person banned status
console.log("Banned1",res.data.data[1].banned); //display the second person banned status
I would like to console.log all 5 person banned status without repeatedly using console.log.
One possible solution, using Array.prototype.forEach:
res.data.data.forEach((data, idx) => console.log('Banned' + idx, data.banned));
If you find an array, you must looping the data, u can use this function
array.map(data => console.log(data));
or
array.forEach((data) => console.log(data));
Read this articles: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration?retiredLocale=id
You can use any kind of for loop to iterate over the data.
My suggestion is to either use a for of loop:
for (const dataItem of res.data.data) {
console.log("Banned", dataItem.banned);
}
or a forEach loop on the array, which would also easily get you the index:
res.data.data.forEach((dataItem, index) => {
console.log(`Banned ${index}`, dataItem.banned);
});