title: React + Axios double POST request to spring RestController (also in fetch, seem not to be OPTIONS)
body: <p>I've read multiple posts about similar problems, but I don't have CORS problem (i don't think) and my network tab <strong>does not show second post being send from client</strong></p>
  
  <p>I'm using Axios and react for my front-end client and after a long time of debugging I found out that something is triggering my RestController method, always twice, always about two minutes in (it's a very long response with a huge amount of data)</p>
  
  <p>Network tab does not show this second <code>POST</code>, but when ran from Postman, everything works as expected (no random double calls)</p>
  
  <p>Axios:</p>
  
  <pre><code>showCurrent = (dateA, dateB) =&gt; {
  
      axios.post("api/allData", {
          params: {
              date_a: dateA,
              date_b: dateB
          }})
          //successful fetch
          .then(res =&gt; this.setState({
              Data: res.data,
              isLoading: false,
              showPage: true,
              home: false,
          }))
          .catch(function (error) {
              //handle errors here
              alert(error.message);
          })
  };
  </code></pre>
  
  <p>and requestMapping:</p>
  
  <pre><code> @RequestMapping(value = "/allData", method = RequestMethod.POST)
   public @ResponseBody String allData(@RequestBody String req)  throws JsonProcessingException {
  
      CDate cDate = parseJSON(req);
      ObjectMapper objectMapper = new ObjectMapper();
      return objectMapper.writeValueAsString(DateRange.getDataForDateRange(date));
  }
  </code></pre>
  
  <p>Controller class also has <code>@RestController</code> annotation</p>
  
  <p>So if i ran query taking under ~2min  it will be ok. but longer than that and the controller will be called twice and everything goes haywire.</p>
  
  <p>I can add more code if needed.. just not sure how to investigate this.</p>
  
  <p>EDIT:</p>
  
  <p>Added Console.log in method doing the post in the client, and in server-side Java.</p>
  
  <pre><code>    console.log("whaaat");
      axios.post("api/allContracts", {
          params: {
              date_a: dateA,
              date_b: dateB
          }}).....
  </code></pre>
  
  <p>whaaat will only be run once, while the post will be run twice and the endpoint will trigger twice....</p>
  
  <p>EDIT2:</p>
  
  <p>What the..... I also added <code>console.log()</code> to every step from click to fetch.
  Nothing will trigger twice except for <code>POST</code> ...</p>
  
  <p>even with reacts native <code>fetch</code> same will occur</p>
  
  <pre><code>showCurrent = (dateA, dateB) =&gt; {
      console.log("whaaat");
      let obj = {};
      let params = {};
      params.date_a = dateA;
      params.date_b = dateB;
      obj.params = params;
  
      this.setState({isLoading: true});
  
      fetch("api/allData", {
          method: 'POST',
          body: JSON.stringify(obj),
          mode: 'cors',
      }).then( res =&gt; {
          return res.json()
      }).then( data =&gt; {
          this.setState({
              Data: data,
              isLoading: false,
              showPage: true,
              home: false,
          })
      }).catch(error =&gt; {
          //handle errors here
          alert(error.message);
      });
  </code></pre>
  
  <p>EDIT 3:
  Still no solution whatsoever....
  I read about preflight OPTIONS request, but there is no such thing on network tab.
  I tried to handle OPTION request in different RequestMapping but that dosent even get triggered....</p>
  
  <p>Tried to put timeout of about 2 million sec in both server and client but that dosent seem to do anything either..
  <strong>Postman does not have this problem, everything works fine</strong></p>