I have a local PouchDB that must sync with a remote CouchDB. I'm trying (so far without success) to replicate the local one (on localhost:8081) to the remote one (on localhost:5984) through a POST call to /_replicate. No matter what I enter in the "source" field of my request, it appends "http:127.0.0.1:5984/" to the source url (or name) and, obviously, I get an error saying it can't find the source db. Of course.
My question (which is, by the way, my very first question on StackOverFlow so please be indulgent) is then: how can I point to the correct db? Thanks!
let url = `http://127.0.0.1:5984/_replicate`;
let data = {
// This is where I struggle
"source" : "http://127.0.0.1:8081/_pouch_local_db",
"target" : `http://127.0.0.1:5984/mydb-${username}`
}
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
}).then(response => {
console.log('Success syncing: ', response);
}).catch(error => console.error('Error while syncing: ', error));