let promise = new Promise(function(resolve, reject) {
setTimeout(() => reject(new Error("Whoops!")), 1000);
});
// reject runs the second function in .then
promise.then(
result => alert(result), // doesn't run
error => alert(error) // shows "Error: Whoops!" after 1 second
);
In the above code snippets even though I am calling reject but promise state is coming as resolved but when I am removing error => alert(error)
from promise.then
then I am getting promise state as rejected
If one is calling reject then promise state should be rejected not resolved am I correct?