Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Using Async and Await in Ionic

$
0
0

@mburger81 wrote:

Hi to every one, we never used await/async, so the question could be also a stupid one but what do we wrong?

This is our code:

  constructor() {
       let text = this.textAsync();
       console.log('text: ', text);
  }


  async textAsync() {
    let val = await this._text();
    return val;
  }

  _text(): Promise<any> {
    return new Promise((resolve, reject) => {
           resolve('TEEEEXXTTTTT');
    })
  }

The log is never text: TEEEEXXTTTTT but something like that
text: ZoneAwarePromise {__zone_symbol__state: null, __zone_symbol__value: Array[0]}

I'm sure there is a simple solution :smile:

thx

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



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