0

Please or Register to create posts and topics.

Question about data access

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

 

 

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.