fetchRestaurantFromURL(callback) {
    if (this.restaurant) { // restaurant already fetched!
      callback(null, this.restaurant)
      return;
    }
    const id = this.getParameterByName('id');
    if (!id) { // no id found in URL
      error = 'No restaurant id in URL'
      callback(error, null);
    } else {
      DBHelper.fetchRestaurantById(id, (error, restaurant) => {
        this.restaurant = restaurant;
        if (!restaurant) {
          console.error(error);
          return;
        }
        this.fillRestaurantHTML();
        callback(null, restaurant)
      });
    }
  }
/**
   * Get current restaurant from page URL.
   */
Get current restaurant from page URL.
Get current restaurant from page URL .
fetchRestaurantFromURL(callback) {
    if (this.restaurant) { 
      callback(null, this.restaurant)
      return;
    }
    const id = this.getParameterByName('id');
    if (!id) { 
      error = 'No restaurant id in URL'
      callback(error, null);
    } else {
      DBHelper.fetchRestaurantById(id, (error, restaurant) => {
        this.restaurant = restaurant;
        if (!restaurant) {
          console.error(error);
          return;
        }
        this.fillRestaurantHTML();
        callback(null, restaurant)
      });
    }
  }
fetchRestaurantFromURL ( callback ) { if ( this . restaurant ) { callback ( null , this . restaurant ) return ; } const id = this . getParameterByName ( 'id' ) ; if ( ! id ) { error = 'No restaurant id in URL' callback ( error , null ) ; } else { DBHelper . fetchRestaurantById ( id , ( error , restaurant ) => { this . restaurant = restaurant ; if ( ! restaurant ) { console . error ( error ) ; return ; } this . fillRestaurantHTML ( ) ; callback ( null , restaurant ) } ) ; } }
Get current restaurant from page URL.
Get current restaurant from page URL .
// restaurant already fetched! // no id found in URL