I want to display all images in Array, I using map but it didn't work
export default class Content extends Component {
constructor(){
super();
this.state = {
gifs: []
}
}
componentDidMount(){
axios.get('https://api.giphy.com/v1/gifs/trending?api_key=nNwaquW24K8gLDmrxGTmawppQoTkXxLQ&tag=&rating=G')
.then( response => {
this.setState({ gifs: [...this.state.gifs, response.data.data] }); // This line is different
})
.catch(function(error){
console.log(error);
})
}
render() {
if (this.state.gifs){
return (
<div className="container">
{this.state.gifs.map( gif =>(
<div className="card mt-5" style={{width: 224 + 'px'}} key={gif[0].id}>
<img className="card-img-top" src={gif[0].images.preview_gif.url}alt="test"></img>
<div className="card-body">
<h4 className="card-title">{gif[0].title}</h4>
</div>
</div>
))}
</div>
);
}
}
}
I expect all images showing up results of the code
And this is my Data