I have a function which takes a function that returns a Promise and I am calling it like so:
const test = (prom) => {
prom()
.then(() => console.log('top level then'))
.catch(() => console.log('top level catch'));
};
test(() => new Promise(() => fetch()
.then(() => console.log('inner level then'))
));
The fetch()
call will return an error because I'm not actually fetching anything but the top level catch is not running - why is that?
The behaviour I'm looking for is that everytime the prom
Promise resolves, the top level then will run and everytime it rejects, the top level catch will run (in addition to any inner level then and catches).