title: Ionic 2 undefined value after calling services provider
body: <p>I ran into a problem when I initiated a value in my page <code>constructor</code> class. I call the <code>provider</code> to load data. Inside <code>service</code> call I can see data was called but when I called my variables outside of service call it said <code>undefined</code>. What happened?</p>
  
  <p><strong>HomePage.ts</strong></p>
  
  <pre><code>export class HomePage {
    public data: any;
    constructor(private nav: NavController, private auth: Auth, private params: NavParams) {
      this.auth.getProfile().then((profile) =&gt; {
        this.data = profile;
         console.log('here i can see data correctly ' + JSON.stringify(this.data));
      })
         console.log('here data undefined ' + JSON.stringify(this.data));
    } 
  </code></pre>
  
  <p><strong>auth.ts provider</strong></p>
  
  <pre><code>     getProfile(){
     return this.getToken().then((token) =&gt; {
     //   console.log(token);
        if (token) {
          return new Promise(resolve =&gt; {
            var headers = new Headers();
            headers.append('Content-Type', 'application/x-www-form-urlencoded');
            try {
              this.http.get('http://laraveldev/api/users/get_user?token=' + token).subscribe(data =&gt; {
                this.profile = data.json().data;
                //console.log('getProfile ' + JSON.stringify(this.profile));
                resolve(this.profile);
              });
            } catch (error) {
              console.log(error);
              this.data = { status: 'error' };
              resolve(this.data);
            }
  
          });
        }
      });
    }
  </code></pre>