Skip to content

Instantly share code, notes, and snippets.

@johnnykoo84
Created April 17, 2019 14:51
Show Gist options
  • Save johnnykoo84/0a72c28d24576c58aacc3b08946ba498 to your computer and use it in GitHub Desktop.
Save johnnykoo84/0a72c28d24576c58aacc3b08946ba498 to your computer and use it in GitHub Desktop.
componentDidMount = async () => {
const articlesData = await axios.get('https://koreanjson.com/posts');
const allArticles = articlesData.data;
this.setState({
allArticles,
currentArticles: allArticles
.filter(article => article.UserId === 1) // UserId 1이 정치 카테고리라고 가정합니다
.slice(0, this.articlesPerPage)
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment