var p = new Promise((res, rej) => {
// reject after 1 second
setTimeout(() => {
rej(123)
}, 1000)
})
p.catch(() => { location.reload() }) // works fine
The code works fine, but since location.reload
is a function, no need to wrap it again with a lambda, so it’s changed to:
var p = new Promise((res, rej) => {
// reject after 1 second
setTimeout(() => {
rej(123)
}, 1000)
})
p.catch(location.reload) // not work
It doesn’t work, there is an exception and not caught by the p.catch()
, why is that ?