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

132
Vistas
I can not send parameter using GET with jQuery to node js REST API

I have developed a rest api in node js with a get endpoint that, based on a received parameter, returns some data. I'm consuming the api from jquery, but I can't send it that parameter it needs in the get request I make. If I make the request from Postman, it works perfectly for me. This is the endpoint code:

async function getIncidentsByState(req,res){
    const params  = req.body;
    const completed = params.completed;
    const idIncident = params.id;
    console.log(completed);
    try {
        const incidents = await Incident.find({completed:completed}).sort({create_at:1});
        if(!incidents){
            res.status(400).send({msg:"Error al obtener las incidencias"});
        }
        else{
            res.status(200).send(incidents);
        }
    } catch (error) {
        res.status(500).send(error);
    }

}

The jquery code that make the request is this:

$.ajax({
    type: "GET",
    dataType: "json",
    contentType: "application/json",
    data: {
        "completed":false
    },
    url: "http://localhost:3600/api/getIncidentsByState",
    
    success: function(data){
        mostrarIncidencias(data);
    }
});

The parameter is not reaching the api and endpoint is printing undefined.

I've tried dozens of different ways,im desesperated.

I would appreciate suggestions on what is going on.

Thanks in advance

about 4 years ago · Juan Pablo Isaza
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