Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform Get request with body - Node js

I'm trying to perform a GET request to elastic search api which is needed in this form

GET /_search
{
    "query": {
        "more_like_this" : {
            "fields" : ["title", "description"],
            "like" : "Once upon a time",
            "min_term_freq" : 1,
            "max_query_terms" : 12
        }
    }
}

I used request But I can't find how to add body to the request.

Any help?

like image 754
abdoutelb Avatar asked Oct 22 '25 16:10

abdoutelb


1 Answers

You can see the document about request(options, callback)

Also, GET method should't send any body, please confirm it's not POST.

request.get('http://localhost:8092/_search', {
  json: true,
  body: {
    "query": {
        "more_like_this" : {
            "fields" : ["title", "description"],
            "like" : "Once upon a time",
            "min_term_freq" : 1,
            "max_query_terms" : 12
        }
    }
  }
})
like image 104
joaner Avatar answered Oct 25 '25 07:10

joaner