static fetchRestaurantById(id, callback) {
    let cached = false;

    this.restaurantsDb.selectRestaurantById(id)
      .then(restaurant => {
        if (restaurant && !cached) {
          cached = true
          return callback(null, restaurant)
        } else {
          fetch(`${this.DATABASE_URL}restaurants/${id}`)
          .then(response => {
            if (response.status === 200) {
              return response.json();
            } else { // Oops!. Got an error from server.
              const error = 'Restaurant does not exist';
              callback(error, null);
            }
          })
          .then(response => {
            const restaurant = response;
            callback(null, restaurant);
          });
        }
      });
  }
/**
   * Fetch a restaurant by its ID.
   */
Fetch a restaurant by its ID.
Fetch a restaurant by its ID .
static fetchRestaurantById(id, callback) {
    let cached = false;
    this.restaurantsDb.selectRestaurantById(id)
      .then(restaurant => {
        if (restaurant && !cached) {
          cached = true
          return callback(null, restaurant)
        } else {
          fetch(`${this.DATABASE_URL}restaurants/${id}`)
          .then(response => {
            if (response.status === 200) {
              return response.json();
            } else { 
              const error = 'Restaurant does not exist';
              callback(error, null);
            }
          })
          .then(response => {
            const restaurant = response;
            callback(null, restaurant);
          });
        }
      });
  }
static fetchRestaurantById ( id , callback ) { let cached = false ; this . restaurantsDb . selectRestaurantById ( id ) . then ( restaurant => { if ( restaurant && ! cached ) { cached = true return callback ( null , restaurant ) } else { fetch ( ` ${ this . DATABASE_URL } ${ id } ` ) . then ( response => { if ( response . status === 200 ) { return response . json ( ) ; } else { const error = 'Restaurant does not exist' ; callback ( error , null ) ; } } ) . then ( response => { const restaurant = response ; callback ( null , restaurant ) ; } ) ; } } ) ; }
Fetch a restaurant by its ID.
Fetch a restaurant by its ID .
// Oops!. Got an error from server.