- During a replication, after PouchDB determines which docs should be pushed up and their contents, replicate's
writeDocs
function is called which in turn calls tobulkDocs
function. - When the target database is a CouchDB, the
bulkDocs
function is aliased to thepouchdb-adapter-http
's_bulkDocs
function. _bulkDocs
then passes the request tofetchJSON
function which then passes it toourFetch
. Ifresponse.ok
is not truthy, an error is thrown here. Note the requirement that response body is valid JSON here. I'm assuming if a proxy returned a 200 status message but returned a body that just said something like "hello", this would throw an error and we would not have success.- The
ourFetch
function passes the request tofetchFun
.fetchFun
looks like it's probably thefetch
method imported from thepouchdb-fetch
package. pouchdb-fetch
'sfetch
export comes from thenode-fetch
package. Thenode-fetch
dependency in PouchDB is listed as being set to version2.6.7
in package.json.- The documentation for
node-fetch
2.x.x
is here.node-fetch
advertises itself as a "window.fetch compatible API on Node.js runtime".
With all this considered, the criteria for successfully pushing up changes to CouchDB from PouchDB are as follows.
- The HTTP request returns as
response.ok == true
according to howwindow.fetch
would determine a response as ok. (A truthy Response.ok is a response with status code of 2xx) - The HTTP request returns a body that can be parsed using
window.fetch
'sresponse.json()
method.
The contents of the response are not inspected.