rxdb-server
Version:
RxDB Server Plugin
38 lines (37 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseResponse = parseResponse;
var _core = require("rxdb/plugins/core");
async function parseResponse(replicationState, fetchResponse) {
if (fetchResponse.status === 426) {
replicationState.outdatedClient$.next();
(0, _core.nextTick)().then(() => replicationState.cancel());
throw (0, _core.newRxError)('RC_OUTDATED', {
url: fetchResponse.url
});
}
if (fetchResponse.status === 401) {
replicationState.unauthorized$.next();
throw (0, _core.newRxError)('RC_UNAUTHORIZED', {
url: fetchResponse.url
});
}
if (fetchResponse.status === 403) {
replicationState.forbidden$.next();
(0, _core.nextTick)().then(() => replicationState.cancel());
throw (0, _core.newRxError)('RC_FORBIDDEN', {
url: fetchResponse.url
});
}
var data = await fetchResponse.json();
if (data.error) {
// TODO
console.log('TODO handle parseResponse error');
console.dir(data);
throw data;
}
return data;
}
//# sourceMappingURL=helpers.js.map