Project 2 Dogs Inventory

Chris Mahfouz
May 9, 2021

In this project I learned how to use API calls.

The project basically allows you to add dogs to a database with all their information. I used react to submit a form and send the data using POST to the database.

Photo by Cristian Castillo on Unsplash
handleSubmit=(e) =>{e.preventDefault()console.log(this.state)fetch('http://localhost:3001/dogs',{method:"POST",headers:{'Content-Type':'application/json',"Accept": "application/json"},body: JSON.stringify(this.state)}).then(res => res.json()).then(data =>{console.log(data)this.props.history.push('/dogslist')})}

As well it is my first time using react router.

Where I created Routes for all the pages, one of the nice feature of react router is the access props.history which allow you from any component to go to a completely new route.

--

--