My Library Docs

Multi-root Sidebar

flex-layout

  • Getting Started

  • Guides

  • Reference

typed-rx-http

  • Getting Started

  • Guides

  • Reference

global-rx-state

  • Getting Started

  • Guides

  • Reference

webflux-fe-dev-assistant

reactive-mongo-dsl


v0.0.11Drag to reorder

HTTP Client

실제 화면에서는 createHttpClient보다 Swagger에서 생성된 service 함수를 더 자주 사용합니다.


공용 client는 한 번만 생성

프로젝트의 API base URL, 공통 header와 에러 메시지는commonService.ts에 모읍니다. 자동 생성된 service는 이 파일의 callApi 또는callApiStream을 import합니다.

commonService.ts
ts
한 번의 응답은 firstValueFrom

검색, 저장, 삭제처럼 한 번 응답하고 끝나는 REST API는 생성된 Observable을firstValueFrom으로 받으면 기존 async 함수 안에서도 자연스럽게 사용할 수 있습니다.

BusinessSearchPage.tsx
tsx

화면에서는 params만 보이지만, 생성된 service 안에는 URL, HTTP method와 response type이 들어 있습니다. query parameter는 항상{ params: { ... } }로 전달합니다.

여러 응답은 subscribe

작업 진행률이나 RSocket stream처럼 여러 값이 도착하는 요청은subscribe로 받고, 컴포넌트가 사라질 때 구독을 해제합니다.

CourtCasePage.tsx
tsx
직접 callApi를 사용하는 경우

Swagger에 아직 반영되지 않은 임시 endpoint를 확인하거나 생성기를 사용하지 않는 프로젝트라면 callApi를 직접 호출할 수 있습니다. 다만 typed-rx-http를 사용하는 일반적인 화면 코드에서 이 형태가 반복된다면 service 생성 흐름을 먼저 연결하는 편이 낫습니다.

TemporaryService.ts
ts
© 2026 Byeolnaerim. All rights reserved.소개개인정보처리방침