How to do it...

  1. Open your command-line application and navigate to your workspace.
  2.  Create a new folder named 3-05-starting-with-resolve.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file that calls Promise.resolve with an empty object as the first argument:
export function main () { 
  Promise.resolve({}) 
} 
  1. 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;
})
}
  1. 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);
})
}
  1. Start your Python web server and open the following link in your browser: http://localhost:8000/.
  1. You should see the following output: