Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!