src/app/Application.js
/**
   * Initializes the app.
   * Called when the DOM has loaded. You can initiate your custom classes here
   * and manipulate the DOM tree. Task data should be assigned to Application.data.
   * The APP_READY event should be emitted at the end of this method.
   */
Initializes the app.
Called when the DOM has loaded. You can initiate your custom classes here
and manipulate the DOM tree. Task data should be assigned to Application.data.
The APP_READY event should be emitted at the end of this method.
Initializes the app . Called when the DOM has loaded . You can initiate your custom classes here and manipulate the DOM tree . Task data should be assigned to Application . data . The APP_READY event should be emitted at the end of this method .
async init() {
    fetch(`https://swapi.booost.bg/api/planets/`)
      .then((resp) => resp.json())
      .then((data) => {
        this.data.count = data.count;
        const promiseArray = [];
        for (let i = 1; i <= this.data.count; i++) {
          const promise = fetch(
            `https://swapi.booost.bg/api/planets/${i}`
          ).then((resp) => resp.json());
          promiseArray.push(promise);
        }
        Promise.all(promiseArray).then((planets) => {
          this.data.planets = planets;
          this.emit(Application.events.APP_READY);
        });
      });
  }
async init ( ) { fetch ( ` ` ) . then ( ( resp ) => resp . json ( ) ) . then ( ( data ) => { this . data . count = data . count ; const promiseArray = [ ] ; for ( let i = 1 ; i <= this . data . count ; i ++ ) { const promise = fetch ( ` ${ i } ` ) . then ( ( resp ) => resp . json ( ) ) ; promiseArray . push ( promise ) ; } Promise . all ( promiseArray ) . then ( ( planets ) => { this . data . planets = planets ; this . emit ( Application . events . APP_READY ) ; } ) ; } ) ; }
Initializes the app.
Initializes the app .
// Initiate classes and wait for async operations here. // const data = await fetch('https://swapi.booost.bg/api/planets/') // console.log(await data.json()) //this.emit(Application.events.APP_READY);