I'm using this method to retrieve some data with an http.get call:
getEmpresas() {
        return this.http.get(this.empresasUrl).map(x => x.json().result[0]); 
    }
Then, I'm calling it from another component in the OnInit method:
empresas: any;
    ngOnInit() {
        // reset login status
        this.authenticationService.logout();
        this.authenticationService.getEmpresas().subscribe(res => {this.empresas = res;});
        console.log(this.empresas);
        // get return url from route parameters or default to '/'
        this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
    }    
But I'm receiving "undefined" in the console output.
When I do something like this:
this.authenticationService.getEmpresas().subscribe(res => {console.log(res);});
It shows the results. Also, if I declare empresas as an array I can do something like this:
this.authenticationService.getEmpresas().subscribe(res => {this.empresas.push(res);});
And it will show me the results, but they will be inside an empty object and that's not what I want.
 
     
    