Angular 4: How to manipulate the "subscriber" element -


i'm refactoring code , i'm using next code:

perfiles.component.ts

this._ps.getperfiles(); 

perfiles.services.ts

getperfiles(){     let path = "perfil"     let dat = this._request.get(path);     console.log(dat); // <-- here appears bottom message     return dat;   } 

request.service.ts

get( path:string ){     let token = this._ls.gettoken();     return this.http.get(`${this.sett.url}/${path}?token=${token}`)                     .map(res => {                       return res.json();                     })                     .subscribe(                       data =>{                         return data.data;                       },                       error =>{                         this.handleerror(error); // function doesn't have problem                       }                     );   } 

my issue next: have receive "subscriber" element, don't know how use it. how data?

please click on next image see big issue.

enter image description here

you must use subscribe in component:

perfiles.component.ts

this._ps.getperfiles().subscribe(anything => {    console.log(anything); }); 

perfiles.services.ts

getperfiles(){     let path = "perfil"     return this._request.get(path); } 

request.service.ts

get( path:string ){     let token = this._ls.gettoken();     return this.http.get(`${this.sett.url}/${path}?token=${token}`)                     .map(res => {                       return res.json();                     });   } 

this way respect layers of angular.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -