mercredi 18 mars 2020

getting data from js promise

I am doing an api call that returns a promise. The call works fine but I want to do treat data contained within the promise. Here is My call:

  let promiseArray = this.get('store').query('member', {query: term, option: this.get('option')});
  promiseArray.then(members  => {console.log(members);
  });

  let var= members;
  console.log(var);

My problem is that this doesn't return an array of my model i.e members, also the second display of members display undefined , it return an object containing a lot of meta data, also the array but inside some meta data.

How could I get simply the array ?




Aucun commentaire:

Enregistrer un commentaire