Created
December 11, 2017 12:52
-
-
Save SamWSoftware/a04e5ba555e6cbdf40821cbf6d3c96b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Blog extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
posts: [] | |
}; | |
} | |
componentDidMount() { | |
axios | |
.get( | |
"http://public-api.wordpress.com/rest/v1/sites/samwcoding.wordpress.com/posts" | |
) | |
.then(res => { | |
this.setState({ posts: res.data.posts }); | |
console.log(this.state.posts); | |
}) | |
.catch(error => console.log(error)); | |
} | |
render() { | |
return ( | |
<div className="blog"> | |
<h1 className="sectionTitle">Articles</h1> | |
{this.state.posts.map(post => <ArticlePreview post={post} />)} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment