Problems getting then and catch to post properly

Tell us what’s happening:
I’m finishing up the last two lessons of ES6, and don’t understand why my code is not behaving properly. All of the tests are passing, but the code does not actually log the error in my console once I catch it. I’ve tried moving it inside/outside the promise block, and the results never change.
I had the same experience with the previous challenge using then and results to post fulfilled promises.

Can someone help me figure out what’s missing?

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)
 });

Your browser information:

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

Challenge: Handle a Rejected Promise with catch

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch

Welcome, brammatt.

Thank you, for pointing this out.

If you really want to see the log, open up your devtools, and you will see it logged there. Also, just for general best practices you should console.error() errors, as opposed to console.log(). I know the challenge says to “log” it, but specifically you should error log it.

Thank you for the response!

I’m still quite novice, and didn’t realize you could simply console the errors (or open dev tools for that matter)! I’m easily missing some best practices by bulldozing through the learning material. So its very helpful to have someone point it out.