title: Vuejs with axios request in vuex store: can't make more than one request, why?
body: <p>I'm building some vuejs dashboard with vuex and axios, between others, and I've been struggling for a while on a pretty pesky problem: it seems I can't make more than one request! All subsequent calls fail with this error:</p>
  
  <blockquote>
    <p>Fetching error... SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Bearer {the_entire_content_of_the_previous_api_response}' is not a valid HTTP header field value.</p>
  </blockquote>
  
  <p>My store looks like that:</p>
  
  <pre><code>import axios from "axios";
  
  const state = {
    rawData1: null,
    rawData2: null
  };
  
  const actions = {
    FETCH_DATA1: ({ commit }) =&gt;
    {
      if (!state.rawData1)
        return axios.get("/api/data1")
        .then((response) =&gt;
        {
          commit("SET_RAW_DATA1", response.data);
        });
    },
  
    FETCH_DATA2: ({ commit }) =&gt;
    {
      if (!state.rawData2)
        return axios.get("/api/data2")
        .then((response) =&gt;
        {
          commit("SET_RAW_DATA2", response.data);
        });
    }
  };
  
  const mutations = {
    SET_RAW_DATA1: (state, data) =&gt;
    {
      state.rawData1 = data;
    },
  
    SET_RAW_DATA2: (state, data) =&gt;
    {
      state.rawData2 = data;
    }
  };
  
  export default
  {
    namespaced: true,
    state,
    actions,
    mutations
  };
  </code></pre>
  
  <p>I don't think my API has any problem, as everything seems to work smoothly via Postman.</p>
  
  <p>Maybe it's obvious for some, but I can't spot what's the matter as I'm still quite a vue noob...</p>
  
  <p>Oh, and I'm handling the axios Promise like this, if this is of any interest:</p>
  
  <pre><code>this.$store.dispatch("api/FETCH_DATA1").then(() =&gt;
  {
    // parsing this.$store.state.api.rawData1 with babyparse
  }).catch((err) =&gt;
  {
    this.errorMsg = "Fetching error... " + err;
  });
  </code></pre>
  
  <p>After @wajisan answer, it does seem to work with "traditional" calls, but not with fetching file calls. I've tried stuff with my Echo api, to no avail... More details there: <a href="https://stackoverflow.com/questions/45558773/serving-files-with-echo-golang">Serving files with Echo (Golang)</a>.</p>
  
  <p>Any ideas, pretty please? :)</p>