<p dir="auto">I have searched for a while if anyone has experienced this but I haven't found anything on this exact regard.</p>
<p dir="auto">I have a vue/cordova application where I perform an axios.all post call where <em>sometimes</em> I get duplicated responses. The times this happend I watch the server logs and I can see that the server is sending distinct values but on google's network tab I see that I don't get the same responses the server is returning. In my tests if the server returns 3 different responses <em>sometimes</em> I get two (or even three) duplicate responses. I have tested in chrome and in firefox.</p>
<p dir="auto">This is a stripped down version of my client code (I only removed unnecessary things):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let solicitudesRequests = []
axios.post(this.endpoint_canal, JSON.stringify(my_object))
      .then((response) =&gt; {
        let autorizaciones = response.data
        if (autorizaciones !== undefined) {
          if (!(autorizaciones instanceof Array)) {
            autorizaciones = [autorizaciones]
          }
          autorizaciones.forEach((autorizacion) =&gt; {
            let another_object = {
                val1: autorizacion.val1
                val2: autorizacion.val2
            }
            solicitudesRequests.push(another_object)
          })
          return axios.all(solicitudesRequests)
        }
      })
      .then((responses) =&gt; {
        responses.forEach((response) =&gt; {
          console.log('response obtained: ', JSON.stringify(response.data)) // here I get duplicated data
          let registro = response.data
          if (registro !== undefined) {
            if (!(registro instanceof Array)) {
              registro = [registro]
            }
            this.solicitudes.push(...registro)
          }
        })
      })
      .catch((exception) =&gt; {
        console.error(exception)
      })"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">solicitudesRequests</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span>
<span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">post</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">endpoint_canal</span><span class="pl-kos">,</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">my_object</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
      <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">let</span> <span class="pl-s1">autorizaciones</span> <span class="pl-c1">=</span> <span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-c1">data</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">autorizaciones</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-kos">(</span><span class="pl-s1">autorizaciones</span> <span class="pl-k">instanceof</span> <span class="pl-v">Array</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-s1">autorizaciones</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-s1">autorizaciones</span><span class="pl-kos">]</span>
          <span class="pl-kos">}</span>
          <span class="pl-s1">autorizaciones</span><span class="pl-kos">.</span><span class="pl-en">forEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">autorizacion</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
            <span class="pl-k">let</span> <span class="pl-s1">another_object</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
                <span class="pl-c1">val1</span>: <span class="pl-s1">autorizacion</span><span class="pl-kos">.</span><span class="pl-c1">val1</span>
                <span class="pl-s1">val2</span>: <span class="pl-s1">autorizacion</span><span class="pl-kos">.</span><span class="pl-c1">val2</span>
            <span class="pl-kos">}</span>
            <span class="pl-s1">solicitudesRequests</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">another_object</span><span class="pl-kos">)</span>
          <span class="pl-kos">}</span><span class="pl-kos">)</span>
          <span class="pl-k">return</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">all</span><span class="pl-kos">(</span><span class="pl-s1">solicitudesRequests</span><span class="pl-kos">)</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">responses</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-s1">responses</span><span class="pl-kos">.</span><span class="pl-en">forEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'response obtained: '</span><span class="pl-kos">,</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// here I get duplicated data</span>
          <span class="pl-k">let</span> <span class="pl-s1">registro</span> <span class="pl-c1">=</span> <span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-c1">data</span>
          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">registro</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-kos">(</span><span class="pl-s1">registro</span> <span class="pl-k">instanceof</span> <span class="pl-v">Array</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
              <span class="pl-s1">registro</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-s1">registro</span><span class="pl-kos">]</span>
            <span class="pl-kos">}</span>
            <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">solicitudes</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span>...<span class="pl-s1">registro</span><span class="pl-kos">)</span>
          <span class="pl-kos">}</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">.</span><span class="pl-en">catch</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">exception</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">error</span><span class="pl-kos">(</span><span class="pl-s1">exception</span><span class="pl-kos">)</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">As I said the server is returning different responses but I get duplicated data, what could be the problem here?</p>
<p dir="auto">Thank you!</p>
<p dir="auto"><strong>Describe the bug</strong><br>
axios.post sends duplicate POST request and ignores the first response, only receives the second response.</p>
<p dir="auto"><strong>To Reproduce</strong><br>
I don't know how to reproduce it since it's occurred.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const axiosAfterLoginRequest = (properties = {}, defaultConfig = {}) =&gt; (
  config = {}
) =&gt; {
  const {
    accessTokenKey = &quot;&quot;,
    accessTokenValue,
    cookieName = STORAGE.USER_TOKEN
  } = properties
  const configMerge = merge(cloneDeep(defaultConfig), config)
  const headers = get(configMerge, &quot;headers&quot;, {})
  const token = getLocalItem(cookieName)
  const accessToken = !isNil(accessTokenValue)
    ? accessTokenValue
    : get(token, accessTokenKey)
  if (!isNil(accessToken) &amp;&amp; !isEmpty(accessToken)) {
    headers.Authorization = `Bearer ${accessToken}`
  }
  return { ...configMerge, headers, ...timestampConfig() }
}
const apiInstance = axios.create({
  baseURL: API_URL
})

const request = axiosAfterLoginRequest(
  { accessTokenKey: &quot;access_token&quot; },
  {
    headers: {
      post: {
        &quot;Content-Type&quot;: &quot;application/json&quot;
      }
    }
  }
)

apiInstance.interceptors.request.use(request)

export const submitApi = (payload) =&gt;
  apiInstance.post(&quot;url&quot;), payload)

export function* submitSaga(action) {
   try {
      const response = yield call(submitApi, action.payload)
      yield put({type: &quot;success&quot;})
   } catch (e) {
      yield put({type: &quot;error&quot;})
   }
}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">axiosAfterLoginRequest</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">properties</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s1">defaultConfig</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">(</span>
  <span class="pl-s1">config</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-kos">{</span>
    accessTokenKey <span class="pl-c1">=</span> <span class="pl-s">""</span><span class="pl-kos">,</span>
    accessTokenValue<span class="pl-kos">,</span>
    cookieName <span class="pl-c1">=</span> <span class="pl-c1">STORAGE</span><span class="pl-kos">.</span><span class="pl-c1">USER_TOKEN</span>
  <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">properties</span>
  <span class="pl-k">const</span> <span class="pl-s1">configMerge</span> <span class="pl-c1">=</span> <span class="pl-en">merge</span><span class="pl-kos">(</span><span class="pl-en">cloneDeep</span><span class="pl-kos">(</span><span class="pl-s1">defaultConfig</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">config</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">headers</span> <span class="pl-c1">=</span> <span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s1">configMerge</span><span class="pl-kos">,</span> <span class="pl-s">"headers"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">token</span> <span class="pl-c1">=</span> <span class="pl-en">getLocalItem</span><span class="pl-kos">(</span><span class="pl-s1">cookieName</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">accessToken</span> <span class="pl-c1">=</span> <span class="pl-c1">!</span><span class="pl-en">isNil</span><span class="pl-kos">(</span><span class="pl-s1">accessTokenValue</span><span class="pl-kos">)</span>
    ? <span class="pl-s1">accessTokenValue</span>
    : <span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s1">token</span><span class="pl-kos">,</span> <span class="pl-s1">accessTokenKey</span><span class="pl-kos">)</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-en">isNil</span><span class="pl-kos">(</span><span class="pl-s1">accessToken</span><span class="pl-kos">)</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-c1">!</span><span class="pl-en">isEmpty</span><span class="pl-kos">(</span><span class="pl-s1">accessToken</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">headers</span><span class="pl-kos">.</span><span class="pl-c1">Authorization</span> <span class="pl-c1">=</span> <span class="pl-s">`Bearer <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">accessToken</span><span class="pl-kos">}</span></span>`</span>
  <span class="pl-kos">}</span>
  <span class="pl-k">return</span> <span class="pl-kos">{</span> ...<span class="pl-s1">configMerge</span><span class="pl-kos">,</span> headers<span class="pl-kos">,</span> ...<span class="pl-en">timestampConfig</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-k">const</span> <span class="pl-s1">apiInstance</span> <span class="pl-c1">=</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">create</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">baseURL</span>: <span class="pl-c1">API_URL</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-k">const</span> <span class="pl-s1">request</span> <span class="pl-c1">=</span> <span class="pl-en">axiosAfterLoginRequest</span><span class="pl-kos">(</span>
  <span class="pl-kos">{</span> <span class="pl-c1">accessTokenKey</span>: <span class="pl-s">"access_token"</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">{</span>
    <span class="pl-c1">headers</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">post</span>: <span class="pl-kos">{</span>
        <span class="pl-s">"Content-Type"</span>: <span class="pl-s">"application/json"</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">)</span>

<span class="pl-s1">apiInstance</span><span class="pl-kos">.</span><span class="pl-c1">interceptors</span><span class="pl-kos">.</span><span class="pl-c1">request</span><span class="pl-kos">.</span><span class="pl-en">use</span><span class="pl-kos">(</span><span class="pl-s1">request</span><span class="pl-kos">)</span>

<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">submitApi</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">payload</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span>
  <span class="pl-s1">apiInstance</span><span class="pl-kos">.</span><span class="pl-en">post</span><span class="pl-kos">(</span><span class="pl-s">"url"</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">payload</span><span class="pl-kos">)</span>

<span class="pl-k">export</span> <span class="pl-k">function</span><span class="pl-c1">*</span> <span class="pl-s1">submitSaga</span><span class="pl-kos">(</span><span class="pl-s1">action</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
   <span class="pl-k">try</span> <span class="pl-kos">{</span>
      <span class="pl-k">const</span> <span class="pl-s1">response</span> <span class="pl-c1">=</span> <span class="pl-k">yield</span> <span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-en">submitApi</span><span class="pl-kos">,</span> <span class="pl-s1">action</span><span class="pl-kos">.</span><span class="pl-c1">payload</span><span class="pl-kos">)</span>
      <span class="pl-k">yield</span> <span class="pl-en">put</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">type</span>: <span class="pl-s">"success"</span><span class="pl-kos">}</span><span class="pl-kos">)</span>
   <span class="pl-kos">}</span> <span class="pl-k">catch</span> <span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">yield</span> <span class="pl-en">put</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">type</span>: <span class="pl-s">"error"</span><span class="pl-kos">}</span><span class="pl-kos">)</span>
   <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">The submit function above is only called once, while the axios.post() is called twice. I have log for my system, in subject <em><strong>Additional context/Screenshots</strong></em></p>
<p dir="auto"><strong>Expected behavior</strong><br>
The request is only sent once.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version [e.g. 0.19.0]</li>
<li>OS: [e.g. Android 10; SM-G970U]</li>
<li>Browser [e.g. Chrome]</li>
<li>Browser Version [e.g. 80]</li>
<li>Additional Library Versions [e.g. React 16.8, redux 4.0.1 react-redux 7.1.0 redux-saga 1.0.3 ]</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2849568/76825630-10b09580-684d-11ea-8b4e-2d28b5e5afd3.png"><img width="1021" alt="Screen Shot 2563-03-17 at 12 26 08" src="https://user-images.githubusercontent.com/2849568/76825630-10b09580-684d-11ea-8b4e-2d28b5e5afd3.png" style="max-width: 100%;"></a></p>
<p dir="auto">You will see <code class="notranslate">request.query.t</code>  for first and second time. it same requested.</p>