0

Axios request which is called from onSubmit the form.

I have tried many times but, on catch the error model closes automatically. I don't want it to close, I want to display the error in models

axios.post("http://localhost:5000/api/login", finaldata)

.then( (res) => {
      } )
          .catch( function (err) {
        console.log("error", err.response.data)
      });

For close button this.props.close which passes from previous component to this

close=()=>{this.props.close()}
David Buck
  • 3,752
  • 35
  • 31
  • 35

1 Answers1

0

Try the below code:

axios.post("http://localhost:5000/api/login",finaldata)
.then(response => { 
    console.log(response)
})
.catch(error => {
    console.log(error.response)
});

You can also refer to this SO answer and this, and this answer

ESCoder
  • 15,431
  • 2
  • 19
  • 42