UNPKG

rxdb-server

Version:
32 lines 941 B
import { newRxError, nextTick } from 'rxdb/plugins/core'; export async function parseResponse(replicationState, fetchResponse) { if (fetchResponse.status === 426) { replicationState.outdatedClient$.next(); nextTick().then(() => replicationState.cancel()); throw newRxError('RC_OUTDATED', { url: fetchResponse.url }); } if (fetchResponse.status === 401) { replicationState.unauthorized$.next(); throw newRxError('RC_UNAUTHORIZED', { url: fetchResponse.url }); } if (fetchResponse.status === 403) { replicationState.forbidden$.next(); nextTick().then(() => replicationState.cancel()); throw 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