<p dir="auto">I am using Axios in my most of my react native projects but I have never met this strange error. I am trying to do a post request to my server but it always giving me Network Error. I tried to do with curl and it worked perfectly and I also tried to visit the IP address from my mobile using a browser and it worked there too. When I try to run the server locally it works perfectly (via reverse TCP)</p>
<p dir="auto"><strong>Bug</strong><br>
Hello, How can i fix duplicate POST and DELETE axios request and i think PUT AND PATCH also. whenever i submit the data or deleting the data using the code below i get duplicate request and response. on the first request it works fine, on the second request a duplicate request/response will happen.</p>
<p dir="auto"><strong>Expected behavior</strong><br>
Remove Duplicate Request and Response.</p>
<p dir="auto"><strong>Code</strong></p>
<p dir="auto"><strong>DELETE REQUEST</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function setDeleteModal(event) {
    const dataToBeDelete = event.target.getAttribute(&quot;id&quot;).toString();
    reportsDeletemodal.classList.add(&quot;is-active&quot;);
    htmlClipped.classList.add(&quot;is-clipped&quot;);
    reportsDeleteClose.addEventListener(&quot;click&quot;, removeDeleteModal, false);

    async function ConfirmDelete(e) {
        e.preventDefault();
        try {
            const responseData = await axios.delete( `/admin/reports/delete/report/${dataToBeDelete}`);
        } catch (error) {
            console.log(error);
        }
        reportsDeletemodal.classList.remove(&quot;is-active&quot;);
        htmlClipped.classList.remove(&quot;is-clipped&quot;);
        loadInitialPagination();
    }

    function cancelDelete() {
        reportsDeletemodal.classList.remove(&quot;is-active&quot;);
        htmlClipped.classList.remove(&quot;is-clipped&quot;);
    }

    reportsModalConfirmBtn.addEventListener(&quot;click&quot;, ConfirmDelete, false);
    reportsModalCancelBtn.addEventListener(&quot;click&quot;, cancelDelete, false);
}

function removeDeleteModal() {
    reportsDeletemodal.classList.remove(&quot;is-active&quot;);
    htmlClipped.classList.remove(&quot;is-clipped&quot;);
}


for (let i = 0, index = removeReportsButtton.length; i &lt; index; i++) {
    removeReportsButtton[i].addEventListener(&quot;click&quot;, setDeleteModal, false);
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">setDeleteModal</span><span class="pl-kos">(</span><span class="pl-s1">event</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">dataToBeDelete</span> <span class="pl-c1">=</span> <span class="pl-s1">event</span><span class="pl-kos">.</span><span class="pl-c1">target</span><span class="pl-kos">.</span><span class="pl-en">getAttribute</span><span class="pl-kos">(</span><span class="pl-s">"id"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">reportsDeletemodal</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-s">"is-active"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">htmlClipped</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-s">"is-clipped"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">reportsDeleteClose</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"click"</span><span class="pl-kos">,</span> <span class="pl-s1">removeDeleteModal</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-v">ConfirmDelete</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-s1">e</span><span class="pl-kos">.</span><span class="pl-en">preventDefault</span><span class="pl-kos">(</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">responseData</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">delete</span><span class="pl-kos">(</span> <span class="pl-s">`/admin/reports/delete/report/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">dataToBeDelete</span><span class="pl-kos">}</span></span>`</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">error</span><span class="pl-kos">)</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-s1">error</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
        <span class="pl-s1">reportsDeletemodal</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-active"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">htmlClipped</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-clipped"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-en">loadInitialPagination</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">function</span> <span class="pl-en">cancelDelete</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">reportsDeletemodal</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-active"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">htmlClipped</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-clipped"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-s1">reportsModalConfirmBtn</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"click"</span><span class="pl-kos">,</span> <span class="pl-v">ConfirmDelete</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">reportsModalCancelBtn</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"click"</span><span class="pl-kos">,</span> <span class="pl-s1">cancelDelete</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">removeDeleteModal</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">reportsDeletemodal</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-active"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">htmlClipped</span><span class="pl-kos">.</span><span class="pl-c1">classList</span><span class="pl-kos">.</span><span class="pl-en">remove</span><span class="pl-kos">(</span><span class="pl-s">"is-clipped"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>


<span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-s1">removeReportsButtton</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">index</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">removeReportsButtton</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"click"</span><span class="pl-kos">,</span> <span class="pl-s1">setDeleteModal</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>POST REQUEST</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="async function insertDataIntoDatabase(event) {
    event.preventDefault();
    addSuccessContainer.style.display = &quot;none&quot;;
    addErrorContainer.style.display = &quot;none&quot;;
    addSuccessContainer.innerHTML = &quot;&quot;;
    addErrorContainer.innerHTML = &quot;&quot;;
    let errorsHtml = &quot;&quot;;

    if (!reportsName.value || !reportsType.value || !reportsDescription.value || !reportsDocument.value === &quot;&quot;) {
       addErrorContainer.innerHTML =
           '&lt;p class=&quot;has-text-centered&quot;&gt;Incomplete Field or invalid Field! please Complete Required fields!&lt;/p&gt;';
           addErrorContainer.style.display = &quot;block&quot;;
   } else {
       try {
           const responseAddData = await axios.post(&quot;/admin/reports&quot;,new FormData(addReportForm));
           console.log(responseAddData);
           if (responseAddData.data.errors) {
               for (let i = 0, index = responseAddData.data.errors.length; i &lt; index; i++) {
                   errorsHtml += `&lt;p class=&quot;has-text-left&quot;&gt;${responseAddData.data.errors[i]}&lt;/p&gt;`;
               }
               addErrorContainer.innerHTML = errorsHtml;
               addErrorContainer.style.display = &quot;block&quot;;
           } else if (!responseAddData.data.errors) {
               addSuccessContainer.innerHTML = '&lt;p class=&quot;has-text-centered&quot;&gt;Data Successfully Added!&lt;/p&gt;';
              addSuccessContainer.style.display = &quot;block&quot;;
                       loadInitialPagination();
          }
      } catch (error) {
         console.log(error.response);
     }
  }
}

addReportForm.addEventListener(&quot;submit&quot;, insertDataIntoDatabase, false);
reportsAddCancel.addEventListener(&quot;click&quot;, removeAddModalContainer, false);
addReportsButton.addEventListener( &quot;click&quot;,showAddModalContainer,false);"><pre class="notranslate"><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">insertDataIntoDatabase</span><span class="pl-kos">(</span><span class="pl-s1">event</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">event</span><span class="pl-kos">.</span><span class="pl-en">preventDefault</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">addSuccessContainer</span><span class="pl-kos">.</span><span class="pl-c1">style</span><span class="pl-kos">.</span><span class="pl-c1">display</span> <span class="pl-c1">=</span> <span class="pl-s">"none"</span><span class="pl-kos">;</span>
    <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">style</span><span class="pl-kos">.</span><span class="pl-c1">display</span> <span class="pl-c1">=</span> <span class="pl-s">"none"</span><span class="pl-kos">;</span>
    <span class="pl-s1">addSuccessContainer</span><span class="pl-kos">.</span><span class="pl-c1">innerHTML</span> <span class="pl-c1">=</span> <span class="pl-s">""</span><span class="pl-kos">;</span>
    <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">innerHTML</span> <span class="pl-c1">=</span> <span class="pl-s">""</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> <span class="pl-s1">errorsHtml</span> <span class="pl-c1">=</span> <span class="pl-s">""</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-s1">reportsName</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-c1">||</span> <span class="pl-c1">!</span><span class="pl-s1">reportsType</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-c1">||</span> <span class="pl-c1">!</span><span class="pl-s1">reportsDescription</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-c1">||</span> <span class="pl-c1">!</span><span class="pl-s1">reportsDocument</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-c1">===</span> <span class="pl-s">""</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
       <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">innerHTML</span> <span class="pl-c1">=</span>
           <span class="pl-s">'&lt;p class="has-text-centered"&gt;Incomplete Field or invalid Field! please Complete Required fields!&lt;/p&gt;'</span><span class="pl-kos">;</span>
           <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">style</span><span class="pl-kos">.</span><span class="pl-c1">display</span> <span class="pl-c1">=</span> <span class="pl-s">"block"</span><span class="pl-kos">;</span>
   <span class="pl-kos">}</span> <span class="pl-k">else</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">responseAddData</span> <span class="pl-c1">=</span> <span class="pl-k">await</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-s">"/admin/reports"</span><span class="pl-kos">,</span><span class="pl-k">new</span> <span class="pl-v">FormData</span><span class="pl-kos">(</span><span class="pl-s1">addReportForm</span><span class="pl-kos">)</span><span class="pl-kos">)</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-s1">responseAddData</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-s1">responseAddData</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">.</span><span class="pl-c1">errors</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
               <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-s1">responseAddData</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">.</span><span class="pl-c1">errors</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">index</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                   <span class="pl-s1">errorsHtml</span> <span class="pl-c1">+=</span> <span class="pl-s">`&lt;p class="has-text-left"&gt;<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">responseAddData</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">.</span><span class="pl-c1">errors</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>&lt;/p&gt;`</span><span class="pl-kos">;</span>
               <span class="pl-kos">}</span>
               <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">innerHTML</span> <span class="pl-c1">=</span> <span class="pl-s1">errorsHtml</span><span class="pl-kos">;</span>
               <span class="pl-s1">addErrorContainer</span><span class="pl-kos">.</span><span class="pl-c1">style</span><span class="pl-kos">.</span><span class="pl-c1">display</span> <span class="pl-c1">=</span> <span class="pl-s">"block"</span><span class="pl-kos">;</span>
           <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">responseAddData</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">.</span><span class="pl-c1">errors</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
               <span class="pl-s1">addSuccessContainer</span><span class="pl-kos">.</span><span class="pl-c1">innerHTML</span> <span class="pl-c1">=</span> <span class="pl-s">'&lt;p class="has-text-centered"&gt;Data Successfully Added!&lt;/p&gt;'</span><span class="pl-kos">;</span>
              <span class="pl-s1">addSuccessContainer</span><span class="pl-kos">.</span><span class="pl-c1">style</span><span class="pl-kos">.</span><span class="pl-c1">display</span> <span class="pl-c1">=</span> <span class="pl-s">"block"</span><span class="pl-kos">;</span>
                       <span class="pl-en">loadInitialPagination</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-k">catch</span> <span class="pl-kos">(</span><span class="pl-s1">error</span><span class="pl-kos">)</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-s1">error</span><span class="pl-kos">.</span><span class="pl-c1">response</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-s1">addReportForm</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"submit"</span><span class="pl-kos">,</span> <span class="pl-s1">insertDataIntoDatabase</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">reportsAddCancel</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"click"</span><span class="pl-kos">,</span> <span class="pl-s1">removeAddModalContainer</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">addReportsButton</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span> <span class="pl-s">"click"</span><span class="pl-kos">,</span><span class="pl-s1">showAddModalContainer</span><span class="pl-kos">,</span><span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios  0.19.2</li>
<li>OS: Windows 10</li>
<li>Chrome</li>
<li>Version 80.0.3987.87</li>
<li>Polyfill.io v3 with async/await feature</li>
<li>Laravel 6.0</li>
</ul>
<p dir="auto"><strong>DATABASE</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13129014/74375736-d56d1200-4e1b-11ea-84f5-86be6262ea00.png"><img src="https://user-images.githubusercontent.com/13129014/74375736-d56d1200-4e1b-11ea-84f5-86be6262ea00.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>POST RESPONSE</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13129014/74375609-98088480-4e1b-11ea-936b-7e0a30a36366.png"><img src="https://user-images.githubusercontent.com/13129014/74375609-98088480-4e1b-11ea-936b-7e0a30a36366.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>DELETE RESPONSE</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13129014/74375830-03525680-4e1c-11ea-8744-68ef5c4f0d6a.png"><img src="https://user-images.githubusercontent.com/13129014/74375830-03525680-4e1c-11ea-8744-68ef5c4f0d6a.png" alt="image" style="max-width: 100%;"></a></p>