Catch syntax clarification

Tell us what’s happening:
Hi someone could clarify this for me please?
I read in the lesson " It is executed immediately after a promise’s reject method is called" and you can see my code calling for ‘catch’ just after ‘reject’. The test is passed but in the solution provided it is called after the ‘then’ method. Any idea?

Thank you

p.s this applies to how the then syntax is explained too

Your code so far


const makeServerRequest = new Promise((resolve, reject) => {
// responseFromServer is set to false to represent an unsuccessful response from a server
let responseFromServer = false;
  
if(responseFromServer) {
  resolve("We got the data");
} else {  
  reject("Data not received");
  makeServerRequest.catch(error => {console.log(error)})
}
});

makeServerRequest.then(result => {
console.log(result);
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Handle a Rejected Promise with catch

Link to the challenge:

Hey @lorenzo0572,
You’re supposed to put your .catch function outside the promise, if it’s not outside, then it will only run inside the function. The Challenge somehow accepted this, but normally, the right way is to put your catch and then outside the promise.

Visualize it like this:

promise((resolve, reject) => {
   // happens first
}).then((result) => {
   // happens after first
}).catch((err) => {
   // happens if error or reject occurs.
});

Thank you! This is helpful