title: How to get value from subscribe inside function? Ionic 3
body: <p>I have this function where I get a JSON file from an URL.
  Now I just need a random object that's in that file that appearently  is this.data.
  but when try to console.log(this.data) outside of the .subscribe function i get undefined. What do i need to use that value in the rest of the function and return it to another function? </p>
  
  <p>Here's my code:</p>
  
  <pre><code>import { HttpClient } from '@angular/common/http';
  import { Injectable } from '@angular/core';
  import { Observable } from 'rxjs/Observable';
  
  
  /*
    Generated class for the AdsProvider provider.
  
    See https://angular.io/guide/dependency-injection for more info on providers
    and Angular DI.
  */
  @Injectable()
  export class AdsProvider {
      adsUrl: string;
    constructor(public http: HttpClient) {
      console.log('Hello AdsProvider Provider');
    }
    getAds() {
      this.adsUrl = 'an url';
      console.log(this.adsUrl);
      console.log('I can get ads');
      // Nu vraag je de file van de server
      let data: Observable&lt;any&gt; = this.http.get(this.adsUrl);
  
      data.subscribe(result =&gt; {
        this.data = result;
        // Nu heb je de JSON file met de advertenties
      });
     console.log(this.data); // this gives me undefined
    }
  }
  </code></pre>