Promise Error Handling
by what1s1ove
JavaScript
const mock = { response: 'У нас есть моки!'};
const sendRequest = () => {
if (Math.random() > 0.5) {
return Promise.reject({ status: 'reject' });
}
return Promise.resolve({ response: 'Важные данные' });
};
const getData = () => {
// место для кода
}
getData().then(console.log);
getData().then(console.log);
getData().then(console.log);
getData().then(console.log);
getData().then(console.log);