Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
How can I keep a clean url when using a form when using javascript and react?

I'm making this form that, for now, redirects, a user to another page after submitting a form. However, after the user is redirected, the form fields pop up in the url. I'm a beginner and I was wondering on how I can keep the url path to just what I specified in the "action" attribute of the form. Here's my code

<div>
     <form action="/test">
          <input type="text" name="login-username" id="login-username" placeholder="Username" />
          <input type="password" name="login-password" id="login-password" placeholder="Password" />
          <input type="submit" name="login-submit-button" id="login-submit-button" />
     </form>
</div>

After clicking the button, the url looks like this:

http://localhost:3000/test?login-username=&login-password=&login-submit-button=Submit

How can I keep it to just

http://localhost:3000/test

Thank you.. any help would be appreciated.

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As mentioned clearly in this answer, default method of form on submit is GET with encoding of type x-www-form-urlencoded, which basically appends input data to the current URL.

Using method POST appends form-data inside the body of the HTTP request (data is not shown in URL).

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda