diff --git a/src/App.js b/src/App.js index ebd949a..43e3c71 100644 --- a/src/App.js +++ b/src/App.js @@ -15,8 +15,40 @@ class App extends React.Component { this.setState({ contacts:response.data }) - } - ) + }) + } + + createUser = (event)=>{ + event.preventDefault(); + axios + .post( + 'https://desolate-thicket-29906.herokuapp.com/api/contacts', + { + name:this.state.newPersonName, + age:this.state.newPersonAge + } + ).then(()=>{ + axios + .get('https://desolate-thicket-29906.herokuapp.com/api/contacts') + .then((response)=>{ + this.setState({ + contacts:response.data + }) + }) + }) + } + + changeNewPersonName = (event)=>{ + this.setState({ + newPersonName: event.target.value + }) + } + + changeNewPersonAge = (event)=>{ + this.setState({ + newPersonAge: event.target.value + }) + } render = ()=>{ @@ -34,9 +66,9 @@ class App extends React.Component {

Create a new Contact

-
- Name:
- Age:
+ + Name:
+ Age: