- Open your command-line application and navigate to your workspace.
- Create a new folder named 3-03-rejecting-promise-errors.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file that creates a promise, and logs messages before and after the promise is created and when the promise is fulfilled:
new Promise(function (resolve) { resolve(); }).then(function (result) { console.log('Promise Completed'); });
- Add a second argument to the promise callback named reject, and call reject with a new error:
new Promise(function (resolve, reject) { reject(new Error('Something went wrong'); }).then(function (result) { console.log('Promise Completed'); });
- Chain a catch call off the ...