Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
function fetchData() { return new Promise((resolve, reject) => { // Simulating an error reject(new Error('Network error')); }); } fetchData() .then( data => console.log('Data:', data), error => console.log('Error handled in then:', error.message) ); // Alternative method using catch fetchData() .then(data => console.log('Data:', data)) .catch(error => console.log('Error handled in catch:', error.message));
Error handled in then: Network error Error handled in catch: Network error