I am currently trying in an angular project to replicate a local database with PouchDB to a remote database hosted on Cloudant.
I have no problem with the replication from the local to the cloudant database but the replication doesn't work from the Cloudant to the local database.
I have the following error:
CustomPouchError {result: {…}}
result:
doc_write_failures: 0
docs_read: 0
docs_written: 0
end_time: "2018-08-03T11:44:24.375Z"
errors: []
last_seq: 0
ok: false
start_time: "2018-08-03T11:44:24.019Z"
status: "aborting"
__proto__:
Object
__proto__:
Error
I have no problem with credential to access to Cloudant.
Here is my code:
constructor() {
this.dbRemote = new PouchDB(`${environment.URL_DB}/${environment.DB}`, {
auth: {
username: `${environment.USERNAME_DB}`,
password: `${environment.PASSWORD_DB}`
},
skipSetup: true
});
this.db = new PouchDB(environment.DB);
this.db.replicate.to(this.dbRemote, {retry: true}).on('complete', () => {
this.db.replicate.from(this.dbRemote, {retry: true}).on('complete', () => {
this.db.sync(this.dbRemote, {
live: true,
retry: true
}).on('change', change => {
this.handleChange(change);
}).on('error', err => {
console.error(`Sync error ${err}`);
});
}).on('paused', function (info) {
console.info('From remote pause: ', info);
}).on('error', err => {
console.error(`Replication from remote error ${err}`);
});
}).on('paused', function (info) {
console.info('To remote pause: ', info);
}).on('error', err => {
console.error(`Replication to remote error ${err}`);
});
}
Note: I have enabled CORS on Cloudant.
Anyone have an idea to understand this error ?
Thanks
EDIT: I tried with an empty database and with one document, it works. The error only occurs when i try to replicate document with attachements.