Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229670

Get Subscribe Data out of function

$
0
0

get function is asynchronous, so:

this.incomingdata = data as any[]; 

ends after:

return this.incomingdata;

So you have to work with Promise:

return new Promise((resolve, reject) => {
      this.http.get('........')
        .subscribe(
         data => {
          resolve(data)
        },
         error => {
          reject(error);
        },
);
    });

And in your controller:

getData().then(data => {
      console.log(data);
//do here what you want
    })

Viewing all articles
Browse latest Browse all 229670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>