diff --git a/src/App.js b/src/App.js index 1e86f1b..70937a1 100644 --- a/src/App.js +++ b/src/App.js @@ -111,11 +111,33 @@ class App extends React.Component { } } + async fetchComments() { + try { + const { data } = await axios.get(API + '/api/comments') + return data + } catch (error) { + console.log(error) + this.setState({ error }) + } + } + + async fetchVotes() { + try { + const { data } = await axios.get(API + '/api/votes') + return data + } catch (error) { + console.log(error) + this.setState({ error }) + } + } + async fetchData() { const articles = await this.fetchArticles() const tasks = await this.fetchTasks() const projects = await this.fetchProjects() - await this.setState({ loading: false, articles, tasks, projects }) + const comments = await this.fetchComments() + const votes = await this.fetchVotes() + await this.setState({ loading: false, articles, tasks, projects, comments, votes }) } componentDidMount() { diff --git a/src/components/articles.js b/src/components/articles.js index 9dc2d9f..f9225f5 100644 --- a/src/components/articles.js +++ b/src/components/articles.js @@ -20,6 +20,11 @@ function Articles(props) { > {article.title}{' '} + ))}