Comment

Comment by trevordixon

Could do something like this:

    async function test() {
        const promise = Math.random() < 0.5 ?
                        Promise.resolve('wow') :
                        Promise.reject('oops');
        try {
            await promise;
        } catch (e) {
            console.log('caught');
            return;
        }
        const result = await promise;
        console.log('result', result);
    }
    test();
parent trevordixon 7 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton