const makeServerRequest = new Promise((resolve, reject) => {
// responseFromServer represents a response from a server
let responseFromServer;
if(responseFromServer) {
resolve("We got the data"); // change this line
} else {
reject("Data not received"); // change this line
}
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0.
Challenge: Complete a Promise with resolve and reject
This is definitely look like a function. If you want to reassure yourself you can additionally try this check in the body of the function you pass to the Promise constructor:
console.log(typeof resolve, typeof reject);
So, to summarize:
typeof Promise; // function (constructor function aka class)
Promise.length; // 1 (Promise connstructor expects 1 argument - callback function)
typeof resolve; // function
typeof reject; // function
// Callback expect 2 arguments and both - again functions
// If you call resolve() - promise resolves
// If you call reject() - promise rejects
You can read more about the Promise object and its methods. You can also check out the specs for the executor function and the resolve/reject function arguments.