title: Typescript: how to structure a fetch API call inside a method that returns a Promise response
body: <p>Maybe a trivial one, but I am new with Typescript and fetch API.
  In an exported class I have a public method <code>remoteFetchSomething</code> like:</p>
  
  <pre><code>export class className {
    remoteFetchSomething = (url : string) : Promise&lt;Response&gt; =&gt; {
      return fetch(url)
        .then(
          (r) =&gt; r.json()
        )
        .catch((e) =&gt; {
          console.log("API errore fetching " + objectType);
        });
    }
  }
  
  export const classInstance = new className();
  </code></pre>
  
  <p>The method queries a remote JSON API service, and in the code, I am using it like:</p>
  
  <pre><code>import { classInstance } from ...
  
  classInstance.remoteFetchSomething('https://example.url')
    .then((json) =&gt; {
      console.log(json);
    }
  )
  </code></pre>
  
  <p>The <code>console.log</code> is actually showing the results, but the <code>remoteFetchSomething</code> returns a <em>Promise</em> and I am unable to parse and access the JSON object values.</p>
  
  <p>I would like to wait for the response before executing the remaining code, but how do I unwrap content from promise? Should I again put another <code>.then</code>? What am I missing? </p>
  
  <p>Thank you.</p>