class IndexPage extends Component{
constructor(props){
super(props);
this.state = {
posts: null
};
}
componentWillMount(){
axios.get('http://www.mocky.io/v2/5a0b3479320000a504e963b9')
.then(res => {
const posts = res.data;
this.setState({posts});
})
.catch(function (error) {
console.log(error);
});
};
render(){
const obj = this.state.posts;
console.log(obj);
return (
<div>
<CardBlock array = {obj}/>
</div>
)
}
}
constructor(props){
super(props);
this.state = {
posts: null,
date: null
};
}
componentDidMount(){
axios.get('http://www.mocky.io/v2/5a0b3479320000a504e963b9')
.then(res => {
const posts = res.data.items;
const date = res.data.feature;
this.setState({posts, date});
})
.catch(function (error) {
console.log(error);
});
};
render(){
const obj = this.state.posts;
const slide = this.state.date;
return (
<div>
<CardBlock items = {obj || []} />
<ShowMoreBlock/>
</div>
)
}
}