In my code, I set up a chain of Promises like this:
let promise = new Promise((resolve, reject) => {
imgToDisplay.onload = () => {
resolve(imgToDisplay.width);
}
})
.then((result) => {
window.URL.revokeObjectURL(imgToDisplay.src);
if (result >= 20)
reject('Image width too large');
})
.then(() => {
//Some action is taken with the image file here if it was not rejected
})
.catch((e) => {
alert(e.message); //An error occurred: "reject is not defined"
});
In the second then()
, I forgot to either call reject
or resolve
. What mistake did I make in this part of the code?