title: axios.post.then is called triggered after everything else
body: <p>I am trying to create a project where a person can create a question and an answer. I am using laravel and Vuex. </p>
  
  <p>I would like to create a variable called Question_id with the response.data after I have called the axios.post to create the question. I would then like to call a function with this Question_id. </p>
  
  <p>I am now noticing though that I cannot do this because when I try to set the question_id variable in .then portion of my axios.post, it happens after I call the other function. In other words, the .then portion happens after all my other code has ran. </p>
  
  <pre class="lang-js prettyprint-override"><code>qaForm(){
    axios
      .post("/api/question/create", this.questionForm)
      .then(response =&gt; {
        question = response.data;
        question_id = question.id;
      })
      .catch(error =&gt; {
        console.log(error.response);
      });
  
    addQuestion(question_id);
  }
  </code></pre>
  
  <p>I can confirm this my consoling.out different steps. If I run this experiment:</p>
  
  <pre class="lang-js prettyprint-override"><code>qaForm(){
    console.log("before axios post"); // runs 1st
  
    axios
      .post("/api/question/create", this.questionForm)
      .then(response =&gt; {
        console.log("inside axios.then"); // runs 3rd
  
        question = response.data;
        question_id = question.id;
      })
      .catch(error =&gt; {
        console.log(error.response);
      });
  
    console.log("after axios post"); // runs 2nd
    addQuestion(question_id);
  }
  </code></pre>
  
  <p>I receive:</p>
  
  <pre><code>before axios post
  after axios post
  inside axios.then
  </code></pre>
  
  <p>Why is it this way? Am I making any mistakes? What are some possible workarounds?</p>