const promise = new Promise(function (resolve, reject) {
    console.log('Состояние pending')
    setTimeout(function () {
        if (Math.random() > 0.5) {
            resolve('данные пришли');
        } else {
            reject('данные не пришли ')
        }
    }, 5000)
})
promise.then(function (success) {
    console.log('успешно' , success)
}).catch(function (error) {
    console.log('ошибка' , error)
})
  
  Состояние pending
Promise {<pending>}
ошибка данные не пришли