Connection

edit

This class represents a single Node, it holds every information we have on the node, such as roles, id, URL, custom headers and so on. The actual HTTP request is performed here, this means that if you want to swap the default HTTP client (Node.js core), you should override this class request method.

const { Client, Connection } = require('@elastic/elasticsearch')

class MyConnection extends Connection {
  request (params, callback) {
    // your code
  }
}

const client = new Client({
  Connection: MyConnection
})