I'm having a problem making multiple request in a loop.
I'm making a react app that renders multiple components called Cards. inside each card I want to make some requests so I got this.
componentWillMount(){
if(this.props.movies){
let promises = []
this.props.movies.forEach((item, i) => {
console.log(item)
let movieUrl = `http://localhost:3000/movies/${item}`
promises.push(axios.get(movieUrl))
})
axios.all(promises).then(res => console.log(res))
}
}
Movies is an array that I get from the father component. so apparently is working because I get results but tit is always with the last element of the last card. Here is an image:
