上QQ阅读APP看书,第一时间看更新
How to do it...
- Open your command-line application and navigate to your workspace.
- Create a new folder named 03-01-creating-and-waiting-for-promises.
- 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, as well as while the promise is executing and after it has been resolved:
// main.js export function main () { console.log('Before promise created'); new Promise(function (resolve) { console.log('Executing promise'); resolve(); }).then(function () { console.log('Finished promise'); }); console.log('After promise created'); }
- Start your Python web server and open the following link in your browser:
http://localhost:8000/.
- You will see the following output: