title: Typescript function return promise
body: <p>I'm having a hard time understanding how to set the return type on a function. </p>
  
  <p>The issue is that this function (api call) could return an array of objects <code>[{}, {}, {}]</code></p>
  
  <p>or and object with some properties, and than the array.</p>
  
  <pre><code>{
    "count": 311,
    "next": "http://127.0.0.1:8000/....",
    "previous": "http://127.0.0.1:8000/...",
    "results": [{}, {}, {}]
  }
  </code></pre>
  
  <p>What I have is the specific API-call function</p>
  
  <pre><code>async function fetchStuff(): Promise&lt;IApiResponse&lt;IStuff[]&gt;&gt; {
      return get({ baseProperty: 'stuff' })
  }
  </code></pre>
  
  <p>Which calls the general "get" method that I created</p>
  
  <pre><code>async function get(baseProperty: string): Promise&lt;IApiResponse&lt;any&gt;&gt; {
      try {
          const { data } = await Vue.$axios.get(baseProperty)
          return data
      } catch (err) {
          console.error(err)
          throw err
      }
  }
  </code></pre>
  
  <p>The interface I created is this</p>
  
  <pre><code>export interface IApiResponse&lt;T&gt; {
      count: number
      next: string
      previous: string
      results: T
  }
  </code></pre>
  
  <p>The problem, as I said is that not all the api calls will return the same thing, how can I allow for different return types in my <code>get</code> method?</p>