mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Fixed whitespace
This commit is contained in:
parent
8e05e64a72
commit
017de0e236
@ -67,43 +67,43 @@ import type { OpenAPIConfig } from './OpenAPI';
|
||||
* @throws ApiError
|
||||
*/
|
||||
export const request = <T>(config: OpenAPIConfig, http: HttpClient, options: ApiRequestOptions): Observable<T> => {
|
||||
const url = getUrl(config, options);
|
||||
const formData = getFormData(options);
|
||||
const body = getRequestBody(options);
|
||||
const url = getUrl(config, options);
|
||||
const formData = getFormData(options);
|
||||
const body = getRequestBody(options);
|
||||
|
||||
return getHeaders(config, options).pipe(
|
||||
mergeMap( headers => {
|
||||
return sendRequest<T>(config, options, http, url, formData, body, headers);
|
||||
}),
|
||||
map(response => {
|
||||
const responseBody = getResponseBody(response);
|
||||
const responseHeader = getResponseHeader(response, options.responseHeader);
|
||||
return {
|
||||
url,
|
||||
ok: response.ok,
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
body: responseHeader ?? responseBody,
|
||||
} as ApiResult;
|
||||
}),
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
if (!error.status) {
|
||||
return throwError(() => error);
|
||||
}
|
||||
return of({
|
||||
url,
|
||||
ok: error.ok,
|
||||
status: error.status,
|
||||
statusText: error.statusText,
|
||||
body: error.statusText,
|
||||
} as ApiResult);
|
||||
}),
|
||||
map(result => {
|
||||
catchErrorCodes(options, result);
|
||||
return result.body as T;
|
||||
}),
|
||||
catchError((error: ApiError) => {
|
||||
return throwError(() => error);
|
||||
}),
|
||||
);
|
||||
return getHeaders(config, options).pipe(
|
||||
mergeMap(headers => {
|
||||
return sendRequest<T>(config, options, http, url, formData, body, headers);
|
||||
}),
|
||||
map(response => {
|
||||
const responseBody = getResponseBody(response);
|
||||
const responseHeader = getResponseHeader(response, options.responseHeader);
|
||||
return {
|
||||
url,
|
||||
ok: response.ok,
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
body: responseHeader ?? responseBody,
|
||||
} as ApiResult;
|
||||
}),
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
if (!error.status) {
|
||||
return throwError(() => error);
|
||||
}
|
||||
return of({
|
||||
url,
|
||||
ok: error.ok,
|
||||
status: error.status,
|
||||
statusText: error.statusText,
|
||||
body: error.statusText,
|
||||
} as ApiResult);
|
||||
}),
|
||||
map(result => {
|
||||
catchErrorCodes(options, result);
|
||||
return result.body as T;
|
||||
}),
|
||||
catchError((error: ApiError) => {
|
||||
return throwError(() => error);
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user