title: Laravel & Vue: Axios GET call returning 200 status but no response
body: <p><strong>EDIT:</strong></p>
  
  <p>So I just got this working by changing the axios get call to a post call, same with the route, any idea why did this work???</p>
  
  <p>from:
  <code>javascript
  axios.get('/globals/get-logged-user')
  </code></p>
  
  <p>and </p>
  
  <p><code>php
  Route::get('/globals/get-logged-user','GlobalsController@getLoggedUser');
  </code></p>
  
  <p>to:</p>
  
  <p><code>javascript
  axios.post('/globals/get-logged-user')
  </code></p>
  
  <p>and </p>
  
  <p><code>php
  Route::post('/globals/get-logged-user','GlobalsController@getLoggedUser');
  </code></p>
  
  <p>I'm trying to get current authenticated user (if exists) for my Header vue component, I'm also using vuex store modules to keep my code organized and decoupled.</p>
  
  <p>The proccess goes like this:</p>
  
  <p>When the header component is mounted() I dispatch the action getLoggedUser.</p>
  
  <p>Now inside the Globals store I make axios get call to route /globals/get-logged-user</p>
  
  <p>If the call is succesfull I update the state, now my Header component should be able to access thelogged user data with the help of mapState vuex helper.</p>
  
  <p>Now what actually happens:</p>
  
  <p><strong>The axios get call is done, it returns a positive 200 status code but the response is blank, nothing gets sent back from the backend.</strong></p>
  
  <p>This is my network tab:</p>
  
  <p><a href="https://i.imgur.com/hlD9bAY.png" rel="nofollow noreferrer">https://i.imgur.com/hlD9bAY.png</a></p>
  
  <p><strong>As you can see the other ajax requests return actual data but the get call returns nothing, I also noticed the type of the GET call is html, could it be this?</strong></p>
  
  <p>My component:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;template&gt;
  &lt;header class="header_maincontainer"&gt;
      &lt;div class="header_small_container"&gt;
           &lt;span&gt;{{ loggedUser.email }}&lt;/span&gt;   
      &lt;/div&gt;
  &lt;/header&gt;
  &lt;/template&gt;
  &lt;!--SCRIPTS--&gt;
  &lt;script&gt;
  import { mapState, mapActions } from 'vuex'
  export default {
  name: 'MainHeader',
  computed: {
      
      //...mapState('Globals', ['allGlobals', 'loggedUser', 'globals']),
      ...mapState('Globals', [ 'loggedUser']),
  },
  
  mounted() {
      console.log(this.$options.name+' component successfully mounted');
      this.getLoggedUser();
  },
  
  methods:{
      //component actions declaration
      ...mapActions('Globals', ['getLoggedUser']),
    
  }
  };
  &lt;/script&gt;
  &lt;!--STYLES--&gt;
  &lt;style scoped&gt;
  
  &lt;/style&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My Globals vuex module:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import axios from 'axios'
  
  //STATE
  const state = {
      
      loggedUser:'',
      
      loadingStatus:0
  }
  
  //GETTERS
  const getters = {
  
  
  
  
  }
  
  //ACTIONS
  const actions = {
  
      
  
      
      getLoggedUser ({ commit }) {
  
          commit( 'SET_LOAD_STATUS', {status: 1} );
          axios.get('/globals/get-logged-user')
          .then((response) =&gt; {
              commit('GET_LOGGED_USER', { loggedUser: response.data.loggedUser })
              console.log(response.data.loggedUser);
              commit( 'SET_LOAD_STATUS', {status: 2} );
          },
          (error) =&gt; {
              console.log(error);
              commit( 'SET_LOAD_STATUS', {status: 3} );
          })
      },
  
  
      
  
  }
  
  //MUTATIONS
  const mutations = {
  
      
      GET_LOGGED_USER (state, loggedUser) {
          state.loggedUser = loggedUser;
      },
  
    
  
  }
  
  export default {
    namespaced: true, state, getters, actions, mutations
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>And my laravel backend:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use App\Models\Globals;
  use Illuminate\Http\Request;
  
  class GlobalsController extends Controller
  {
      
      
  
  
      public function getLoggedUser(){
  
          $loggedUser = Auth::user();
      
          return response()-&gt;json([
          
              'loggedUser' =&gt; $loggedUser
  
          ]);
  
      }
  
  
     
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please help me, I'm still stuck with this after all these days.</p>