如何解决将远程 Cloudant DB 同步到本地 PouchDB
我已经创建了一个 Cloudant 数据库,并且正在尝试将它同步到我的本地 PouchDB。但是,我没有任何成功。
var PouchDB = require('pouchdb');
var find = require('pouchdb-find');
PouchDB.plugin(find);
const cors = require('cors');
var remoteDB = new PouchDB('URL',{"auth": {"username":"USR","password": "PASSWD"}});
console.log('Remote database created Successfully.');
var localDB = new PouchDB('myLocalDB',{ skip_setup: true });
console.log('Local database created Successfully.');
localDB.sync(remoteDB)
remoteDB.info().then(function (info) {
console.log(info);
})
执行我的代码时,这是我控制台中的输出
node client.js
Remote database created Successfully.
Local database created Successfully.
(node:28532) UnhandledPromiseRejectionWarning: #<Object>
(node:28532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:28532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:28532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
也许这行不正确
var remoteDB = new PouchDB('URL',"password": "PASSWD"}});
但是,我查看了 PouchDB,似乎这是调用它的正确方法。任何使用 PouchDB 的人都可以进来看看我在这里做错了什么?
谢谢, 乔
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。