IMPORTANT!
This forum is now archived. Click here for the New Support Forum
Question about data access
Quote from Ingo on March 30, 2018, 1:45 pmHi,
I get the data from the API.
this.appDataService.getAppData().subscribe(appData => this.onAppSettingsLoad(appData));in my method :
onAppSettingsLoad(appData: AppData) { console.log(appData); console.log(appData.dbversion); }my service:
export class AppDataService { constructor( private http: HttpClient, private appDataEndpoint: AppDataEndpoint ) { } getAppData() { return this.appDataEndpoint.getAppDataEndpoint<AppData>(); } };my endpoint service:
@Injectable() export class AppDataEndpoint extends EndpointFactory { private readonly _appDataUrl: string = "/api/home/appSettings"; constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) { super(http, configurations, injector); } getAppDataEndpoint<T>(): Observable<T> { return this.http.get<T>(this._appDataUrl, this.getRequestHeaders()) .catch(error => { return this.handleError(error, () => this.getAppDataEndpoint()); }) } }
the log appData show in the console:
{dbVersion: 1}
dbVersion
:
1but in the second log there are appData.dbversion undefined.
What I make wrong?
In advance thanks for any hint and tip
Hi,
I get the data from the API.
this.appDataService.getAppData().subscribe(appData => this.onAppSettingsLoad(appData));
in my method :
onAppSettingsLoad(appData: AppData) { console.log(appData); console.log(appData.dbversion); }
my service:
export class AppDataService { constructor( private http: HttpClient, private appDataEndpoint: AppDataEndpoint ) { } getAppData() { return this.appDataEndpoint.getAppDataEndpoint<AppData>(); } };
my endpoint service:
@Injectable() export class AppDataEndpoint extends EndpointFactory { private readonly _appDataUrl: string = "/api/home/appSettings"; constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) { super(http, configurations, injector); } getAppDataEndpoint<T>(): Observable<T> { return this.http.get<T>(this._appDataUrl, this.getRequestHeaders()) .catch(error => { return this.handleError(error, () => this.getAppDataEndpoint()); }) } }
the log appData show in the console:
{dbVersion: 1}
dbVersion
:
1
but in the second log there are appData.dbversion undefined.
What I make wrong?
In advance thanks for any hint and tip
Quote from Ingo on March 30, 2018, 2:27 pmI found my bug.
The cause was the different uppercase and lowercase letters of the properties of the Javascript model and the model of the server.
I found my bug.
The cause was the different uppercase and lowercase letters of the properties of the Javascript model and the model of the server.
IMPORTANT!
This forum is now archived. Click here for the New Support Forum