Directions for this challenge say:
Add the then method to your promise. Use result as the parameter of its callback function and log result to the console.
Here’s the code with my code marked //my code:
let responseFromServer = true;
if(responseFromServer) {
resolve("We got the data");
} else {
reject("Data not received");
}
makeServerRequest.then(result => {//my code
console.log(result);//my code
})//my code
});```
The code passes the test but nothing is logged to the console.
The challenge is: ES6: Handle a Fulfilled Promise with then
Here’s the starter code:
const makeServerRequest = new Promise((resolve, reject) => {
// responseFromServer is set to true to represent a successful response from a server
let responseFromServer = true;
if(responseFromServer) {
resolve("We got the data");
} else {
reject("Data not received");
}
});