title: Get returned data after posting with axios (vue+ laravel)
body: <p>I wanted to create a custom login system with vue as my frontend, laravel handling the api, and axios as the controller between the two. I wanted to get the returned data from my <code>AuthController</code>. Here's my codes:</p>
  
  <p>Vue:</p>
  
  <pre><code>export default {
  name: 'Login',
  data(){
      return {
          user_input: [
              {email: ''},
              {password: ''}
          ],
          csrf: document.querySelector('meta[name="csrf-token"]').getAttribute('content')
      }
  },
  methods: {
      userLogin: function(){
          let params = Object.assign ({}, this.user_input)
          axios.post('/api/login/', params)
          .then(function(response){
              console.log(response.data)
          })
          .catch(function(error){
              console.log(error)
          })
  
      }
  }
  }
  </code></pre>
  
  <p>And in the AuthController:</p>
  
  <pre><code>public function login(Request $request) {
      return "Hey";
  }
  </code></pre>
  
  <p>The output on the console is this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
  &lt;meta name="csrf-token" content="40lajOfdWdmIQ1yP49dyeyToidT79CntGyHqrNRD"&gt;
  &lt;link rel="stylesheet" href="/css/app.css"&gt;
  &lt;title&gt;VueComplete&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="app"&gt;
      &lt;App/&gt;
  &lt;/div&gt;
  &lt;script src="http://vuecomplete.test/js/app.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>(This is basically my app.blade.php view).</p>
  
  <p>why isn't it returning "Hey"?</p>
  
  <p>I also tried:</p>
  
  <pre><code>public function login(Request $request) {
      return $request-&gt;email;
  }
  </code></pre>
  
  <p>But it produced the same result. How can I fix this? 
  Thanks a ton!</p>
  
  <h1>Update</h1>
  
  <p>I am using vue-router to create an SPA within laravel. In my routes (web.php) I have somewhat like this:</p>
  
  <pre><code>Route::get('/{any}', 'SPAController@index')-&gt;where('any','.*');
  </code></pre>
  
  <p>Which then in the controller:</p>
  
  <pre><code>public function index() {
      return view('app');
  }
  </code></pre>
  
  <p>That's probably why it's returning the app.blade.php's entire html code. <br>
  Is there a way to access the <code>api/login</code> while still using vue-router's SPA capabilities?</p>