From cd19364efca57d24eb9840356418f80cad7b5dfa Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Wed, 30 Oct 2019 11:40:44 -0400 Subject: [PATCH] Can now display post body on profile page --- twistter-frontend/src/pages/user.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/twistter-frontend/src/pages/user.js b/twistter-frontend/src/pages/user.js index 7633295..af0243c 100644 --- a/twistter-frontend/src/pages/user.js +++ b/twistter-frontend/src/pages/user.js @@ -63,6 +63,7 @@ class user extends Component { }); }) .catch(err => console.log(err)); + axios .get("/getAllTopics") .then(res => { @@ -71,16 +72,25 @@ class user extends Component { }) }) .catch(err => console.log(err)); + + axios + .get("/getallPostsforUser") + .then(res => { + console.log(res.data); + this.setState({ + posts: res.data + }) + }) + .catch(err => console.log(err)); } + render() { const classes = this.props; - //const authenticated = this.props.user.authenticated; let profileMarkup = this.state.profile ? (

{this.state.profile}

) : (

loading username...

); - let topicsMarkup = this.state.topics ? ( this.state.topics.map(topic => ) : (); + let postMarkup = this.state.posts ? ( + this.state.posts.map(post =>

{post.body}

) + ) : (

My Posts

); + return ( @@ -118,13 +132,12 @@ class user extends Component { />
- {/*authenticated && */}
-

Post

+ {postMarkup}
);