added get request userline function

This commit is contained in:
Aditya Sankaran
2019-10-01 14:03:15 -04:00
parent 7969d3b10b
commit 754c2f2d75
4 changed files with 42 additions and 9 deletions

View File

@@ -9,16 +9,29 @@ class Userline extends Component {
{
super(props);
this.state = {
microBlogs : []
}
}
render() {
componentDidMount() {
axios.get('http://localhost:5001/twistter-e4649/us-central1/api/getallPostsforUser')
.then(res => {
const post = res.data;
this.setState({microBlogs : post})
})
}
render() {
return (
<p>Hi</p>
<ul>
{ this.state.microBlogs.map(microBlog => <p>{microBlog.body}</p>)}
</ul>
)
}
}
}
export default Userline;
export default Userline;

View File

@@ -37,10 +37,11 @@ class Writing_Microblogs extends Component {
},
{ headers: { 'Content-Type': 'application/json'} }
)
console.log(response.data);
event.preventDefault();
this.setState({value: '', title: '',characterCount: 10})
}
handleChangeforPost(event) {
@@ -51,6 +52,7 @@ class Writing_Microblogs extends Component {
const charCount = event.target.value.length
const charRemaining = 10 - charCount
this.setState({characterCount: charRemaining })
}