So I have this Service in Angular2
fetchData(){
return this.http.get('https://ng-workout.firebaseio.com/Workouts/.json').map(
(res) => res.json()
);
}
And then this Component
export class HomeComponent {
workouts = [];
constructor(private dataService: DataService){
}
ngOnInit(){
this.dataService.fetchData().subscribe(
data=> this.workouts =data
);
console.log(this.workouts);
}
}
So the thing is, when i console log 'this.workouts' it returns 0, an empty array. Shouldn't there be all the records from the json file?