title: React Router Adds URL Query Params on POST Request
body: <p>Hello my fellow nerds,</p>
  <p>I am running into an issue where when I make a POST request (using <strong>Axios</strong> library inside of <strong>React</strong> function), it automatically appends all of the data from the &quot;Create a User&quot; form into search parameters in the URL of the page upon submission. I don't like this because I'd rather this stay hidden within the POST request, not flung out onto the page URL.</p>
  <p>Image: <a href="https://i.stack.imgur.com/Akz8E.png" rel="nofollow noreferrer">URL after user was created</a></p>
  <p>This is a direct result of <strong>React Router</strong> adding the data sent in the request of the body being appended to the location.search of react router's history object. So, naturally, since the react router history object is mutable, I tried adding this to the response of the submission:</p>
  <pre><code>this.props.location.search.replace({*some random parameter stuff here*});
  </code></pre>
  <p>This was in hopes it would remove all of that stuff from the URL and redirect to the page without search parameters. Anyways, I have seen a few other posts similar in nature but they don't seem to answer this exact question.</p>
  <p><strong>TL;DR</strong>: I am trying to send a POST request without React Router adding my req.body data to the params in my URL and the location.search object.</p>
  <h2><strong>MY CODE:</strong></h2>
  <p><em>Users.js</em>: (front end)</p>
  <pre><code>handleSubmit (e) {
      Axios.post(`${server}/s/admin/users/create`, {
          headers: {
              'Content-Type': 'application/json'
          },
          data: {
              firstName: this.state.firstName,
              lastName: this.state.lastName,
              username: this.state.username,
              password: this.state.password,
              email: this.state.email
          }
      }).then((res) =&gt; {
          console.log(res);
      }).catch(err =&gt; console.log(err));
  }
  </code></pre>
  <p><em>users.js</em>: (back end)</p>
  <pre><code>app.post(&quot;/s/admin/users/create&quot;, (req, res) =&gt; {
  let rb = req.body.data;
  let newUser = new User({
      _id: uid.time(),
      orgID: req.session.orgID,
      email: rb.email,
      username: rb.username,
      password: bcrypt.hashSync(rb.password, hashRate),
      firstName: rb.firstName,
      lastName: rb.lastName,
      data: { exist: &quot;true&quot; },
      settings: { exist: &quot;true&quot; }
  });
  
  // Save new owner to db
  newUser.save((err, data) =&gt; {
      if (err) return console.error(err);
      res.json({info: `A new user, ${newUser.firstName} ${newUser.lastName}, has been created successfully.`});
  });
  </code></pre>
  <p>});</p>
  <p>Thank you!</p>
  <p>P.S. This is my first post, thank you for your patience. I've tried searching and solving this issue for about a day now.</p>