title: Using Vue & Axios to POST data to PHP
body: <p>I am trying to use Axios within Vue to POST data set by the user to PHP. I am creating a JSON object using PHP and want to add filtering it to the object. I created filtering inputs for the user to apply and I want to take those user inputs and pass the values to PHP using Axios.</p>
  
  <p>So what I have so far is:</p>
  
  <pre><code>onSubmit () {
  axios.post('http://website.com/index.php', {
    'region': this.selectedRegion,
    'jobType': this.selectedJobType,
    'category': this.selectedCategory,
  }).then(response =&gt; {
    if (response.data.error) {
      console.log('error', response.data.error)
    } else {
      this.postStatus = true;
  
      console.log('success', response.data.message)
    }
  }).catch(error =&gt; {
    console.log(error.response)
  });
  
  }
  </code></pre>
  
  <p>So the data variables of selectedRegion, selectedJobType, and selectedCategories are set in Vue based on what the user sets in the input. The user then would need to click a submit button to run the onSubmit function. The trouble I am having now is taking that data and adding it into PHP.</p>
  
  <p>Edit: Trying to clarify I little more. I want to take the data from JS and then be able to output that data in PHP after it is posted. </p>
  
  <p>Edit2: I tried adding: </p>
  
  <pre><code>&lt;?php
  if(isset($_POST['region'])) {
    $region = $_POST['region'];
  echo $region
      }
  
   ?&gt;
  </code></pre>
  
  <p>to the PHP file to output the region value, but that then gives me an error saying the variable is undefined</p>