Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
How to get form data using POST method and fetch api?

I wanted help to get data from post method using fetch api? I tried the below code but can anyone help me understand how to work on it?

The script.js file as below,

//select the elements
const submitBtn = document.getElementById("submit");

//get data from the form
const formData = submitBtn.addEventListener('click', function (info) {
    fetch(info)
        .then((response) => {
            console.log(response);
            return response.json();
        })
        .then((data) => {
            let datas = data;

            datas.map(function (data) {
                const node = document.createElement('li');
                const textNode = document.createTextNode(`${author.blog}`);
                node.appendChild(textNode);
                console.log(node);
            })
        })
        .catch(function (error) {
            console.log(error);
        })
});

HTML in short:

 <form method="post">
<button type="submit" onSubmit="formData" class="btn btn-primary" id="submit">Submit</button>
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda