- Open your command-line application and navigate to your workspace.
- Create a new folder named 3-05-starting-with-resolve.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file that calls Promise.resolve with an empty object as the first argument:
export function main () {
Promise.resolve({})
}
- Chain a then call off of resolve, and attach rocket boosters to the passed object:
export function main () {
Promise.resolve({}).then(function (rocket) {
console.log('attaching boosters');
rocket.boosters = [{
count: 2,
fuelType: 'solid'
}, {
count: 1,
fuelType: 'liquid'
}];
return rocket;
})
}
- Add a final then call to the chain that lets you know when the boosters have been added:
export function main () {
Promise.resolve({})
.then(function (rocket) {
console.log('attaching boosters');
rocket.boosters = [{
count: 2,
fuelType: 'solid'
}, {
count: 1,
fuelType: 'liquid'
}];
return rocket;
})
.then(function (rocket) {
console.log('boosters attached');
console.log(rocket);
})
}
- Start your Python web server and open the following link in your browser: http://localhost:8000/.
- You should see the following output: