First, you should try to remove:id in post methods for example
if your get an error in the frontend don't initialize the:id route component
<Route path={"/yourpath/:id"} component ={yourcomponent}/>
if you get the error on the backend.
axios.post('http://localhost:3001/driver/update/'+this.props.match.params.id,driver )
.then(res => console.log(res.data))
.catch((error) =>{
console.log(error)})
Because in the route you defined params as id so you don't specify in the post method URL. Also, use async-await every time you update setState and like async componentDidMount () and use await like await this.setState({yourState}). if you use await don't forget to use async before the function.
* Be the first to Make Comment