title: Angular Promise : unable to get value
body: <p>I'm coming from the python world, and am a beginner in Angular / ts / js way of programming.</p>
  
  <p>The <code>Ionic storage.get()</code> method returns a <code>Promise</code>. How should I get the value of token in order to send it with my http query ?</p>
  
  <p>For now, i'm trying this faulty bloc :</p>
  
  <pre><code>get(url: string): Observable&lt;Response&gt; {
    let token = "";
    this.storage.get('token')
        .then(token =&gt; token = token);
  
    return this.http.get(url, { "Authorization" : token});
  }
  </code></pre>
  
  <p>Of course, the request leaves with token = "" instead of the one that should have come back after the promise resolution.</p>
  
  <p>I can see not other method in Promise than <code>then()</code> and <code>catch()</code>. I have considered the following code :</p>
  
  <pre><code>get(url: string): Observable&lt;Response&gt; {
    return this.storage.get('token').then(
      token =&gt; {
        return this.http.get(url, { "Authorization": token } )
    );
  });
  </code></pre>
  
  <p>But then, <code>get(url)</code> returns a <code>Promise&lt;Observable&lt;Response&gt;&gt;</code> instead of <code>Observable&lt;Response&gt;</code> and this does not help me much.</p>
  
  <p>If the anwser lies within the use of defer ($q <a href="https://docs.angularjs.org/api/ng/service/" rel="nofollow noreferrer">https://docs.angularjs.org/api/ng/service/</a>$q) , someone please could tell me how this class can be imported into angular / ionic ?</p>
  
  <p>Thank you for your assistance :)</p>