Hi,

I am having issues with Observables service layer invocation, I am getting
data till the service layer but not propagating to component layer not sure
what was wrong.   Can you please let me know if I am doing something wrong
here.

Please do the needful in this regard

*In HelperUtils.ts  (This is the same class for the http REST API)*

getResource(url: string): Observable<any[]> {
        this.headers.set('Api_key', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
eyJuYW1lIjoiZGRuIiwidXNlcm5hbWUiOiJhZG1pb' +
            'iIsImlhdCI6MTQ5NDkwMzgwMiwiZXhwIjoxNDk0OTkwMjAyfQ.
QsHQ7EHu6WHBusgoNuzNYVtBAamuyiunKZw-ur_rFx8');
        this.options = new RequestOptions({ headers: this.headers });
        console.log('URL at  HttpUtils', this.getServer() + url);
        console.log('Options at  HttpUtils', this.options);
        return this.http
            .get(this.getServer() + url, this.options)
            .map(this.retrieveData)
            .catch(this.handleException);
 }


*In DNSService.ts*

 getDNS(): Observable<Dns[]> {
        return this.helperUtils
            .getResource('databases')
            .subscribe(
                res => this.data = res,
                    // make sure you get data here.
                    // console.log('Data from Service API layer',
this.data),
                error => console.log('Error from backend API', +error),
                () => console.log('Done')
        );
    }



*In the DNSComponent.ts*

result: Dns[];
 this.dnsSvc
              .getDNS()
              .subscribe(
                  res => {
                      console.log('In component result class:===>' + res);
                      this.result = res;
                      console.log('In component class:===>' + this.result);
                  },
              // make sure you get data here.
              // console.log('Data from API layer', +res);
                  error => console.log('Error from backend API', +error),
              () => console.log('Done')
           );


*DNSModel.ts*

export class Dns {
    public dnsname: string;
}

Thanks and Regards
Swaroop

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to