Filter data from http provider


Hi, I can’t filter an array I get from an http. I use this provider to get data from my API. This data which is used to create a list, has a field “level_pre” which I like to use to filter data. In first page, I’ll show level_pre = 1 items, in page 2 I’ll show level_pre 2 items, and so on. First, my provider, that gets “preguntes” JSON, from API:

            return Promise.resolve(;
        return new Promise(

Then in page I have

constructor(public navCtrl: NavController, public navParams: NavParams, public preguntesprovider:PreguntesProvider, public loadingCtrl:LoadingController) {
      this.loading = this.loadingCtrl.create({
          content: '<ion-spinner ></ion-spinner>'
        }); = navParams.get('place');
      this.preguntes = this.preguntes.filter((item) => {
        return item.level_pre == '1';

I’d like to user param “place”, which is an objecte, get its level_pre, and filter “preguntes”, using this value, and show in page only this level_pre items. I’ve made some test, with a “1” value, but the filter doesn’t work. I think it’s something with object this.preguntes…

Thank you for your help,


You are filtering something that doesn’t exist yet. The filter must be inside the then() block.


Yes, @rapropos, you’re right. Thank you!