const getData = () => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            if (Math.floor(Math.random()*2)){
                resolve('1');
            } else {
                reject({isError: true, code: 700, message: 'message'});
            }            
        },300);
    })
};

Promise

getData()
.then((response) => {
    console.log('## Promise SUCCEED :', response);
})
.catch((e) => {
    console.error('## Promise FAILED :', e);
});

Async/Await

const run = async () => {
    const response = await getData();
    console.log(response);
};
run();

Error Handling

const run = async () => {
    try {
        const response = await getData();
        console.log('## async await SUCCEED :', response);
    } catch(e) {
        console.error('## async await FAILED :', e);
    }
};
run();