Hi I would like to use axios in a forEach loop in react, but it doesn't work, how should I change this code so that genre, will take the values from genres array
const [Carousels, setCarousels] = useState([]);
const genres = ["BestRated", "Newest"];
useEffect(() => {
const getCarousels = async (genre) => {
try {
let res = await axios.get(`http://localhost:4000/api/carousels/`+genre);
setCarousels([...Carousels, res.data]);
console.log(Carousels);
} catch (err) {
console.log(err);
}
}
getCarousels();
});