Beginner inquiry concerning typescript/angular4+/ionic4. I have a service set up to make backend REST calls, and based on the response received, I need to store that data in local storage for future reference. However, I am encountering a type conversion error. Any advice would be appreciated.
this.locationService.saveLocationNew(this.newLocation).subscribe(res=> {
this.locationInfo = res;
console.log('Response from backend'+ this.locationInfo);
this.storage.set(StorageKeys.LOCATION_DATA, this.locationInfo);
this.locationInfo = null;
this.locationInfo = <AddLocationResponse>this.storage.get(StorageKeys.LOCATION_DATA); --> Error occurs here.
});
This is how my service is structured:
saveLocationNew(request: AddLocationData): Observable<AddLocationResponse> {
return this.httpClient.post<AddLocationResponse>(this.addLocationUrl, request , { headers: Constants.createHeader()}); --> I follow a different approach without using then and mapping responses to res.json, as it's not necessary in Ionic4
}