title: Using es6 class to extend Axios
body: <p>I'm interesting in creating an API wrapper and extending from axios using es6 classes. How is this possible? Axios has a method .create() which allows you to generate a new axios object</p>
  
  <pre><code>class Api extends Axios {
    constructor(...args){
      super(..args)
      this.defaults.baseURL = 'https://api.com'
    }
    cancelOrder (id) {
      return this.put(`/cancel/order/${id}`)
    }
  }
  </code></pre>
  
  <p>I know I have access to this <code>let instance = axios.create()</code>.</p>
  
  <p>Any thoughts?</p>
  
  <p><strong>Attempt 1</strong></p>
  
  <pre><code>import axios from 'axios'
  const Axios = axios.create()
  
  class Api extends Axios {
    constructor (...args) {
      super(...args)
      this.defaults.baseURL = 'https://api.com'
    }
    cancelOrder (id) {
      return this.put(`/cancel/order/${id}`)
    }
  }
  
  let api = new Api()
  
  api.cancelOrder('hi')
    .then(console.log)
    .catch(console.log)
  </code></pre>
  
  <p><strong>Attempt 2</strong></p>
  
  <pre><code>import axios from 'axios'
  
  class Axios {
    constructor () {
      return axios.create()
    }
  }
  
  class Api extends Axios {
    constructor () {
      super()
      this.defaults.baseURL = 'https://api.com'
    }
    cancelOrder (id) {
      return this.put(`/cancel/order/${id}`)
    }
  }
  
  let api = new Api()
  
  console.log(api.__proto__)
  
  api.cancelOrder('hi')
    .then(console.log)
    .catch(console.log)
  </code></pre>