couchdbpouchdb

How can I fetch CouchDB server version via PouchDB


All I want to get is this object:

{
  "couchdb": "Welcome",
  "version": "3.1.1",
  "git_sha": "ce596c65d",
  "uuid": "ff0e85a5e76efdf116e1394e1a94a70f",
  "features": [
    "access-ready",
    "partitioned",
    "pluggable-storage-engines",
    "reshard",
    "scheduler"
  ],
  "vendor": { "name": "The Apache Software Foundation" }
}

But I can't figure out how can I fetch the root server URL.

Maybe there is another option in PouchDB how to get CouchDB server version.

EDIT:

I have found this function is source code, but it doesn't get info described in the comment above the function. GitHub link

  // Calls GET on the host, which gets back a JSON string containing
  //    couchdb: A welcome string
  //    version: The version of CouchDB it is running
  api._info = function (callback) {
    setup().then(function () {
      return ourFetch(genDBUrl(host, ''));
    }).then(function (response) {
      return response.json();
    }).then(function (info) {
      info.host = genDBUrl(host, '');
      callback(null, info);
    }).catch(callback);
  };

Solution

  • After a digging a bit into the source code, I have found the solution.

    infoDb
          .fetch('/')
          .then((res) => {
            return res.json();
          })
          .then((res) => {
            console.log('FETCH', res);
          });
    

    Result:

    {
        "couchdb": "Welcome",
        "version": "3.1.1",
        "git_sha": "ce596c65d",
        "uuid": "ff0e85a5e76efdf116e1394e1a94a70f",
        "features": [
            "access-ready",
            "partitioned",
            "pluggable-storage-engines",
            "reshard",
            "scheduler"
        ],
        "vendor": {
            "name": "The Apache Software Foundation"
        }
    }