I am passing the reject portion of the parametor, however I’m failing at the resolve.
The instructions say:
Make the promise handle success and failure. If responseFromServer
is true
, call the resolve
method to successfully complete the promise.
Which I guess I don’t understand how to get the correct condition statement for checking if it is true. Or what I’m supposed to write for the proper conditional statement.
If someone could please help me figure this out. e.g. point me to the write thing to read so I can figure out how to solve it myself.
I have read on MDN about Promise - JavaScript and several other articles and still can’t figure it out.
Thanks in advance.
const makeServerRequest = new Promise((resolve, reject) => {
// responseFromServer represents a response from a server
let responseFromServer;
if(responseFromServer === true) {
resolve("We got the data");
} else {
reject("Data not received");
}
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Challenge: ES6 - Complete a Promise with resolve and reject
Link to the challenge: