I am struggling with my Angular Service as I am trying to return a promise with a Typed Array but keep encountering the following error: src/app/city.service.ts(52,22): error TS2339: Property 'places' does not exist on type 'CityService'. I cannot figure out what mistake I am making.
getPlace(coordinates : Coordinates) {
// var places : Array<Place> = [];
let promise = new Promise((resolve, reject) => {
this.http.get('http://localhost:3000/api/place/', {params: coordinates})
.toPromise()
.then(
res => { // Success
var places: Array<Place>;
this.places = res.results.map(item => {
var place = new Place();
place.place_id = item.place_id;
place.name = item.name;
place.vicinity = item.vicinity;
place.coordinates = new Coordinates();
place.coordinates.latitude = item.geometry.location.lat;
place.coordinates.longitude = item.geometry.location.lng;
return place;
});
resolve(this.places);
},
msg => { // Error
reject(msg);
}
);
});
return promise;
}