Is axios written without catch in the same way as using catch?

1. It is written

on the official website.
axios.post(url, data)
    .then(response => {
        console.log(response);
    })
    .catch(error => {
           console.log(error);
    })

2. The company project is written as

axios.post(url, data)
    .then(response => {
        console.log(response);
    }, error => {
        console.log(error);
    })

I am a rookie. I haven"t used then and catch before. Are these two writing methods the same? Thank you

Apr.05,2021

first of all, this is not about axios catch but about the then of new Promise ()
Ruan Yifeng wrote very clearly in the promise document

then Reject thencatch
// bad
promise
  .then(function(data) {
    // success
  }, function(err) {
    // error
  });

// good
promise
  .then(function(data) { //cb
    // success
  })
  .catch(function(err) {
    // error
  });
thentry/catchcatchthen

there is no saying that who is good or bad mainly depends on the business. It may be easy to understand some

in this way.

catch

 console.log(response);

the above code reports an error and cannot be captured.

Menu