freeCodeCamp Challenge Guide: Complete a Promise with resolve and reject

Complete a Promise with resolve and reject


Solutions

Solution 1 (Click to Show/Hide)
const makeServerRequest = new Promise((resolve, reject) => {
  // responseFromServer represents a response from a server
  let responseFromServer;

  if(responseFromServer) {
    resolve("We got the data");
  } else {	
    reject("Data not received");
  }
});
2 Likes