0

I use Ionic Framework and i try to display data from pouchdb.

I call the readParcelle function from ionViewWillEnter then i have this error : TypeError: Cannot set property 'items' of undefined

 readParcelle() {

    this.parcelles = new PouchDB('parcelles');

        //Get parcelles from PouchDB

        this.parcelles.allDocs({
            include_docs: true
            }).then(function (result) {

              var items= [];

              this.items = result;

            }).catch(function (err) {
            console.log(err);
        });

  }

 ionViewWillEnter() : void
   {   

      this.readParcelle();

   }
Frank33
  • 11
  • 5
  • Please read about the "this" keyword in JavaScript. The error tells you that this.items are not defined in the context of the callback-function from your db-layer; using a arrow function would fix it – enno.void Dec 19 '18 at 09:33
  • i resolved it thanks – Frank33 Dec 19 '18 at 09:56

0 Answers0