'Axios post form on submit, reactjs localhost - 404 error status

I want to test post request on my localhost reactjs form. After the form us submitet I want to redirect to another page to which I'm posting the form. Right now I'm getting 404 error, I was trying different version of axios code examples, but nothing worked so far.

Here is my post function

  const formData = {
    description: description,
    netto: netto,
    brutto: brutto,
    vat: vat
  };

  function handleSubmit() {
    axios.post(
      "/FormSubmit",
      {
        description: description,
        netto: netto,
        brutto: brutto,
        vat: vat
      },
      {
        headers: {
          "Content-type": "application/json; charset=UTF-8",
        }
      }
    )
    .then((response) => {
    if (response.status == 200) alert("Login Success");
    })
    .catch((error) => {
        console.log(error);
    });
  };

Here is my form

    return(
      <form action='/FormSubmit' id='form' onInvalid={handleEmptyDescription}>
        <div className="vertical-space">
          <label>Description </label>
          <textarea id='descr' type='text'
          value={description}
           onChange={handleDescriptionChange}
           maxLength='25'
           required/>
           <span> {wordCounter}/255</span>
        </div>
        <div>
        <label>Send confirmation</label>
        <input  type='radio' name='radio' required />
        <span>YES</span>
        <input  type='radio' name='radio' required />
        <span>NO</span>
        </div>
        <div className="vertical-space">
          <label>VAT </label>
          <select value={vat} onChange={handleVatChange} required>
            <option value="" disabled defaultValue >Choose VAT</option>
            <option value="1.19">19%</option>
            <option value="1.21">21%</option>
            <option value="1.23">23%</option>
            <option value="1.25">25%</option>
          </select>
        </div>
        <div className="vertical-space">
          <label>Price netto EUR </label>
          <input id='netto' pattern="\d+((\.|,)\d+)?" disabled={nettoDisabled} type='text'
          value={netto}
          onChange = {handleNettoChange}
          onKeyUp = {handleWrongInput}
          required/>
        </div>
        <div>
          <span id='wrongInput' className='hiddenMessage messageStyle'> Please, input number</span>
        </div>
        <div className="vertical-space">
          <label>Price brutto EUR </label>
          <input id='brutto' value={brutto} disabled type='text'/>
        </div>
        <button onClick={handleSubmit} type='submit'>Submit</button>
      </form>
    )
  }


Solution 1:[1]

axios.post( "/FormSubmit", { description: formData.description, netto: formData.netto, brutto: formData.brutto, vat: formData.vat },

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohammad Mohammadi