When retrieving data from the Google API within the function of the details.ts
file, I have set up a service as shown below. However, I am encountering a Typescript error stating
Property 'then' does not exist on type 'void'
.
this.typeApi.getTypeDetails(baseUrl).then(data => {
});
In the type-api.service.ts
file, I am fetching data from the Google API in the following manner:
import { Injectable } from '@angular/core';
import { Http /*, Response*/ } from '@angular/http';
import 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class TypeApi {
constructor(public http: Http ) {}
getTypeDetails(PlaceUrl){
this.http
.get(PlaceUrl)
.map(res => res.json())
.subscribe(
(data) => data,
(err) => err); // Handle if fails
}
}
And in the package.json file:
"dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@ionic-native/core": "3.1.0",
"@ionic-native/geolocation": "^3.4.4",
"@ionic-native/launch-navigator": "^3.4.4",
"@ionic-native/splash-screen": "3.1.0",
"@ionic-native/status-bar": "3.1.0",
"@ionic/storage": "2.0.0",
"font-awesome": "^4.7.0",
"ionic-angular": "2.3.0",
"ionic2-rating": "^1.2.0",
"ionicons": "3.0.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2"
},
"devDependencies": {
"@ionic/app-scripts": "1.1.4",
"typescript": "2.0.9"
},