@@ -67,43 +67,43 @@ import type { OpenAPIConfig } from './OpenAPI';
67
67
* @throws ApiError
68
68
*/
69
69
export const request = <T >(config: OpenAPIConfig, http: HttpClient, options: ApiRequestOptions): Observable<T > => {
70
- const url = getUrl(config, options);
71
- const formData = getFormData(options);
72
- const body = getRequestBody(options);
73
-
74
- return getHeaders(config, options).pipe(
75
- mergeMap( headers => {
76
- return sendRequest<T >(config, options, http, url, formData, body, headers);
77
- }),
78
- map(response => {
79
- const responseBody = getResponseBody(response);
80
- const responseHeader = getResponseHeader(response, options.responseHeader);
81
- return {
82
- url,
83
- ok: response.ok,
84
- status: response.status,
85
- statusText: response.statusText,
86
- body: responseHeader ?? responseBody,
87
- } as ApiResult;
88
- }),
89
- catchError((error: HttpErrorResponse) => {
90
- if (!error.status) {
91
- return throwError(() => error);
92
- }
93
- return of({
94
- url,
95
- ok: error.ok,
96
- status: error.status,
97
- statusText: error.statusText,
98
- body: error.statusText,
99
- } as ApiResult);
100
- }),
101
- map(result => {
102
- catchErrorCodes(options, result);
103
- return result.body as T;
104
- }),
105
- catchError((error: ApiError) => {
106
- return throwError(() => error);
107
- }),
108
- );
70
+ const url = getUrl(config, options);
71
+ const formData = getFormData(options);
72
+ const body = getRequestBody(options);
73
+
74
+ return getHeaders(config, options).pipe(
75
+ mergeMap(headers => {
76
+ return sendRequest<T >(config, options, http, url, formData, body, headers);
77
+ }),
78
+ map(response => {
79
+ const responseBody = getResponseBody(response);
80
+ const responseHeader = getResponseHeader(response, options.responseHeader);
81
+ return {
82
+ url,
83
+ ok: response.ok,
84
+ status: response.status,
85
+ statusText: response.statusText,
86
+ body: responseHeader ?? responseBody,
87
+ } as ApiResult;
88
+ }),
89
+ catchError((error: HttpErrorResponse) => {
90
+ if (!error.status) {
91
+ return throwError(() => error);
92
+ }
93
+ return of({
94
+ url,
95
+ ok: error.ok,
96
+ status: error.status,
97
+ statusText: error.statusText,
98
+ body: error.statusText,
99
+ } as ApiResult);
100
+ }),
101
+ map(result => {
102
+ catchErrorCodes(options, result);
103
+ return result.body as T;
104
+ }),
105
+ catchError((error: ApiError) => {
106
+ return throwError(() => error);
107
+ }),
108
+ );
109
109
};
0 commit comments