Hi guys 
Working on my first project in Ionic more or less following this tutorial.
In general trying to call the REST Api, with prayer types , and present it on the screen.
The issue is that, when calling loadPrayerType() from the constrcutor (or on click the button), method prayerProvider.load() return “undevined” value. While inside itselfs it has data (retrieve from API, log, etc). Cheked it on DebugTool on Chrome.
Any suggestion?
BTW I’m newbie on Ionic and JavaSript in general - what probably is a reason :-).
File wspolnota.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {PrayerProvider} from '../../providers/prayer/prayer';
import { HttpModule } from '@angular/http';
@Component({
selector: 'page-wsp-lnota',
templateUrl: 'wsp-lnota.html',
providers: [PrayerProvider]
})
export class WspLnotaPage {
public prayer_type: any;
constructor(public navCtrl: NavController, public prayerProvider: PrayerProvider) {
this.loadPrayerType();
}
loadPrayerType(){
this.prayerProvider.load().then(data => {
this.prayer_type = data.results;
});
}
}
File prayer.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class PrayerProvider {
data: any;
constructor(public http: Http) {
console.log('Hello PrayerProvider Provider');
this.data = null;
}
load() {
debugger;
if (this.data) {
console.log("Mam juĹĽ dane "+ this.data);
// already loaded data
return Promise.resolve(this.data);
}
// don't have the data yet
return new Promise(resolve => {
this.http.get('http://localhost:8000/book/')
.map(res => res.json())
.subscribe( data => {
this.data = data;
resolve(this.data);
});
});
}
}