@equinor/fusion-framework-module-http
Advanced tools
Comparing version 2.1.8 to 2.2.0
@@ -6,2 +6,8 @@ # Change Log | ||
## [2.2.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-http@2.1.8...@equinor/fusion-framework-module-http@2.2.0) (2022-12-08) | ||
### Features | ||
- **http:** throw error when selector error ([dc0aa35](https://github.com/equinor/fusion-framework/commit/dc0aa35cbc44fb0503a9431ab728b81d8a3af290)) | ||
## 2.1.8 (2022-12-06) | ||
@@ -8,0 +14,0 @@ |
export * from './configurator'; | ||
export * from './provider'; | ||
export * from './module'; | ||
export * from './errors'; | ||
export { default } from './module'; | ||
//# sourceMappingURL=index.js.map |
@@ -17,2 +17,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { jsonSelector } from '../selectors'; | ||
import { HttpResponseError } from '../../errors'; | ||
export class HttpClient { | ||
@@ -73,3 +74,15 @@ get request$() { | ||
return fromFetch(uri, init); | ||
}), switchMap((x) => this._prepareResponse(x)), tap((x) => this._response$.next(x)), switchMap((x) => (selector ? selector(x) : Promise.resolve(x))), takeUntil(this._abort$)); | ||
}), switchMap((x) => this._prepareResponse(x)), tap((x) => this._response$.next(x)), switchMap((response) => { | ||
if (selector) { | ||
try { | ||
return selector(response); | ||
} | ||
catch (err) { | ||
throw new HttpResponseError('failed to parse response', response, { | ||
cause: err, | ||
}); | ||
} | ||
} | ||
return of(response); | ||
}), takeUntil(this._abort$)); | ||
return response$; | ||
@@ -76,0 +89,0 @@ } |
export * from './configurator'; | ||
export * from './provider'; | ||
export * from './module'; | ||
export * from './errors'; | ||
export type { IHttpClient } from './lib/client'; | ||
export { default } from './module'; |
{ | ||
"name": "@equinor/fusion-framework-module-http", | ||
"version": "2.1.8", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -52,3 +52,3 @@ "main": "dist/esm/index.js", | ||
}, | ||
"gitHead": "4707c5d5b0676133961be6fe0eb67200877b5f6b" | ||
"gitHead": "4241afc72be403a4e998993e6c54119dd9394edd" | ||
} |
@@ -10,4 +10,6 @@ /** | ||
export * from './errors'; | ||
export type { IHttpClient } from './lib/client'; | ||
export { default } from './module'; |
import { firstValueFrom, of, Subject } from 'rxjs'; | ||
import { switchMap, takeUntil, tap } from 'rxjs/operators'; | ||
import { catchError, switchMap, takeUntil, tap } from 'rxjs/operators'; | ||
import { fromFetch } from 'rxjs/fetch'; | ||
@@ -11,2 +11,3 @@ | ||
import type { FetchRequest, FetchRequestInit, FetchResponse, IHttpClient, StreamResponse } from '.'; | ||
import { HttpResponseError } from '../../errors'; | ||
@@ -144,3 +145,19 @@ export type HttpClientCreateOptions< | ||
switchMap((x) => (selector ? selector(x) : Promise.resolve(x))), | ||
/** execute selector */ | ||
switchMap((response) => { | ||
if (selector) { | ||
try { | ||
return selector(response); | ||
} catch (err) { | ||
throw new HttpResponseError( | ||
'failed to parse response', | ||
response as Response, | ||
{ | ||
cause: err, | ||
} | ||
); | ||
} | ||
} | ||
return of(response); | ||
}), | ||
/** cancel request on abort signal */ | ||
@@ -147,0 +164,0 @@ takeUntil(this._abort$) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182779
78
1294