in packages/search-ui-elasticsearch-connector/src/transporter/ApiClientTransporter.ts [54:80]
async performRequest(searchRequest: SearchRequest): Promise<ResponseBody> {
if (!fetch)
throw new Error("Fetch is not supported in this browser / environment");
let host = this.config.host;
if (this.config.cloud) {
host = getHostFromCloud(this.config.cloud);
}
const searchUrl = new URL(`/${this.config.index}/_search`, host);
const response = await fetch(searchUrl.href, {
method: "POST",
body: JSON.stringify(searchRequest),
headers: {
"Content-Type": "application/json",
...this.headers,
...(this.config?.apiKey
? { Authorization: `ApiKey ${this.config.apiKey}` }
: {})
}
});
const json = await response.json();
return json;
}