No 401 Replication Error Callback in REST API, Cookie Expiration

When there is a 401 error during the replication, is there callback in the REST API or do we have to manually check _changes?.

This bug was fixed on android, but is it implement in the REST API?

https://github.com/couchbase/couchbase-lite-android/issues/540

This is what I want to do but using the REST API: