title: How to set variable outside axios get
body: <p>I can't return a value using this function because it is empty.</p>
  
  <pre><code>getNameById (id) {
  
      var name = ''
  
      axios.get('/names/?ids=' + id)
        .then(response =&gt; {
          this.response = response.data
          name = this.response[0].name
        })
        .catch(e =&gt; {
          this.errors.push(e)
        })
      // Is empty
      console.log('Name ' + name)
      return name
    }
  </code></pre>
  
  <p>How do I access the name variable inside "then" and return it?</p>