← Ada adatlapja
AgentAda
1. Typed
2. Interceptors and
Angular HTTP-kapcsolatok
Típusos HTTP-szolgáltatásokat készít követhető paraméterezéssel, megszakítással és javítható hibajelzésekkel.
angular-http
Nézd meg, miben segítMikor hasznos?
Akkor használd, ha Angular-képernyők API-val kommunikálnak, és egységes hibakezelésre van szükséged.
Miben segít neked?
- Elválasztja az átvitt adatot a felületi modelltől, helyesen kódolja a paramétereket.
- Változatlan eredetiből készít módosított kéréseket és kérésenkénti kezelési szabályokat.
- Megkülönbözteti a jogosultsági, ellenőrzési és hálózati hibákat.
Például ezt kérheted
Készíts rendeléskeresést és mentést típusos szolgáltatással, elavult keresések megszakításával és mezőhibák megjelenítésével. Írj gyorsan két keresőkifejezést, majd ments hibás irányítószámmal. Csak az utolsó találatok jelenjenek meg, a mezőhiba mellett pedig maradjon meg a többi módosítás.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
HTTP & Backend Integration
Keep HTTP communication in typed Angular services and interceptors with clear request lifecycles, error normalization and zero leaked server secrets.
1. Typed HttpClient services and parameters
- Encapsulate API calls in dedicated domain/data services rather than calling
HttpClientdirectly inside components. - Type every request and response (
this.http.get<OrderSummaryDto>(...)) and map transport DTOs into domain models where the API shape differs from UI needs. - Build query strings with
HttpParams(new HttpParams({ fromObject: ... })) or theparamsoption object rather than manual string concatenation so special characters are properly URL-encoded. - Never embed server-side API keys or secrets in Angular environment files or client bundles.
2. Interceptors and HttpContext
- Match the project's interceptor registration (
withInterceptors([fn])inprovideHttpClientvsHTTP_INTERCEPTORSclass providers). - Remember
HttpRequestandHttpHeadersare immutable: always pass the result ofreq.clone({ setHeaders: ... })tonext(clonedReq). - Use
HttpContextandHttpContextToken<T>to pass per-request metadata (such as skipping auth headers, suppressing global error toasts, or tagging cache policy) to interceptors cleanly without polluting URLs or headers.
3. Error handling, retries and cancellation
- Normalize
HttpErrorResponse(status0network/CORS failure,401/403auth,422validation errors,5xxserver failures) so components receive actionable error states. - Apply
retry({ count, delay })only to idempotent reads (GET) or transient network errors, never blindly to non-idempotentPOST/PATCHmutations. - Understand that unsubscribing from
HttpClientaborts the in-flight XHR/fetchrequest; useswitchMapfor reads/searches andexhaustMaporconcatMapfor mutations.
Before you finish
- All
HttpClientcalls live in typed services and useHttpParamsfor query parameters. - Interceptors clone requests immutably and use
HttpContextTokenfor per-request flags. -
HttpErrorResponsestatuses (0,401/403,422,5xx) and cancellation are handled predictably.
Csomagban lévő fájlok 2
LICENSE.txtSKILL.md
