I am new to the elasticsearch and JavaScript development. I am trying to use the code below, so I can do regular REST calls and get JSON back.
Here is my code that I am using in section
function myFunction() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://d77511xxx.us-central1.gcp.cloud.es.io:9243', true);
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('user:password'));
xhr.send('{"query":{"match_all":{}}}');
}
Here is my additional setting that I am using in elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "/.*/"
http.cors.allow-credentials: true
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, Authorization"
But for some reason I am getting 401 or other issues.
Here is my ElasticSearch Server Link: http://d77511xxx.us-central1.gcp.cloud.es.io:9243