如何通过 PouchDB 获取 CouchDB 服务器版本

How can I fetch CouchDB server version via PouchDB

我只想得到这个对象:

{
  "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" }
}

但我不知道如何获取根服务器 URL。

也许 PouchDB 中还有另一个选项如何获取 CouchDB 服务器版本。

编辑:

我发现这个函数是源代码,但它没有得到函数上方注释中描述的信息。 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);
  };

深入研究源代码后,我找到了解决方案。

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

结果:

{
    "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"
    }
}