async bindBikeStationsToMap()

in assets/src/modules/signup/Home.tsx [131:153]


  async bindBikeStationsToMap(query_string='*') {
    const result = await this.bikeStations(query_string);

    const stationList: BikeStation[] = [];

    for (let i = 0; i < result.hits.hits.length; i++) {
      const item = result.hits.hits[i]._source;

      const new_station: BikeStation = {
        stationId: item.station_id,
        name: item.name,
        lon: item.lon,
        lat: item.lat,
        numOfBikes: (Object.prototype.hasOwnProperty.call(item, 'num_bikes_available') ? item.num_bikes_available : 0),
        capacity: (Object.prototype.hasOwnProperty.call(item, 'capacity') ? item.capacity : 0),
        lastReported: item.last_reported
      };
      stationList.push(new_station);
    }

    const bikeStations = stationList;
    this.setState({ bikeStations });
  }