Promise example #4

by mbychawski

HTML

<div id="log"></div>

CSS

body {
    font-family: monospace;
}

Babel + JSX

Promise.resolve()
    .then(()=>{
        log('onFulfilled#1 throws');
        throw new Error('exceprion from onFulfilled#1')
    })
    .catch((reason)=>{
        log('onRejected#2 got reason:', reason);
    });
    
    
function log(...strings){
    let node = document.createElement('div');
    node.innerText = strings.join(' ');
    document.getElementById('log').appendChild(node);
}