title: typescript/angular pass value out of this?
body: <p>So in normal javascript if I wanted to assign a value to a variable and then use that value outside of a function it would be done by declaring the variable first and then define it's value in the function. I'm brand new to typescript and angular so I am missing how to do this.</p>
  
  <p>In the code below I am trying to get the value from a method in a service and then pass that value into my return. (I hope that makes sense). However I keep getting undefined on <code>console.log(url)</code> with no other errors.</p>
  
  <pre><code>emailsAPI() {
      let url: any  
      this.apiUrlsService.urlsAPI().subscribe(
          data =&gt; {
              this.results = data
              url = this.results.emails
          }
      );
      console.log(url)
      return this.http.get('assets/api/email_list.json')
  }
  </code></pre>
  
  <p>api-urls service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpErrorResponse } from '@angular/common/http';
  
  @Injectable()
  export class ApiUrlsService {
  
      constructor(
          private http: HttpClient
      ) { }
  
      urlsAPI () {
          return this.http.get('assets/api/api_urls.json')
      }
  
  }
  </code></pre>