Community코딩 & 개발github.com

analogjs/angular-http

Angular v20+에서 resource(), httpResource(), HttpClient를 사용하여 HTTP 데이터를 가져옵니다. API 호출, 신호 기반 데이터 로딩, 요청/응답 처리 및 인터셉터에 사용됩니다. 데이터 가져오기, API 통합, 로딩 상태, 오류 처리 또는 Observable 기반 HTTP를 신호 기반 패턴으로 변환할 때 트리거됩니다.

angular-http란 무엇인가요?

이 스킬은 Angular v20+ 애플리케이션에서 HTTP 데이터 가져오기를 구현하는 방법을 제공합니다. Angular 팀이 도입한 최신 신호 기반 API인 `resource()`, `httpResource()`와 기존의 `HttpClient`를 활용하여 API 호출, 데이터 로딩, 요청/응답 처리 및 인터셉터를 효율적으로 관리합니다. 주요 사용 사례로는 API 통합, 로딩 상태 관리, 오류 처리, 그리고 Observable 기반 HTTP 패턴을 신호 기반 패턴으로 마이그레이션하는 작업이 포함됩니다. 이 스킬은 `resource()`, `httpResource()`, `HttpClient`, `HttpInterceptorFn`, `provideHttpClient(withInterceptors(...))`와 같은 핵심 Angular HTTP 기능을 지원하며, `withFetch()`를 사용한 페치 백엔드 선택 및 타입 안전한 신호 기반 데이터 흐름을 강조합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/analogjs/angular-skills/tree/main/skills/angular-http

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

angular-http은(는) 무엇을 하나요?

Angular v20+에서 resource(), httpResource(), HttpClient를 사용하여 HTTP 데이터 가져오기를 구현합니다. API 호출, 신호 기반 데이터 로딩, 요청/응답 처리 및 인터셉터에 사용됩니다. 데이터 가져오기, API 통합, 로딩 상태, 오류 처리 또는 Observable 기반 HTTP를 신호 기반 패턴으로 변환할 때 트리거됩니다.

개요

이 스킬은 Angular 애플리케이션에서 HTTP 데이터를 가져오는 최신 접근 방식을 제공합니다. Angular v20+에서 도입된 신호 기반 API인 resource()와 httpResource()를 활용하여 반응형 데이터 흐름을 단순화합니다.

주요 기능

  • resource(): 신호 기반 비동기 리소스 로더
  • httpResource(): resource()의 HTTP 특화 래퍼
  • HttpClient: 기존 Observable 기반 HTTP 클라이언트
  • HttpInterceptorFn: 함수형 인터셉터
  • 신호 기반 데이터 흐름 (Observable 대체)

사용 예시

1. httpResource() 사용

import { httpResource } from '@angular/common/http';

// 간단한 GET 요청
const userResource = httpResource<User>('/api/user/1');

// 신호로 상태 읽기
console.log(userResource.value()); // 데이터
console.log(userResource.isLoading()); // 로딩 상태
console.log(userResource.error()); // 오류

2. resource() 사용

import { resource } from '@angular/core';

const userResource = resource({
  request: () => ({ id: userId() }),
  loader: async ({ request }) => {
    const response = await fetch(`/api/users/${request.id}`);
    return response.json();
  },
});

3. HttpClient + 신호 패턴

import { HttpClient } from '@angular/common/http';
import { toSignal } from '@angular/core/rxjs-interop';

class UserService {
  private http = inject(HttpClient);
  
  // Observable을 신호로 변환
  readonly users = toSignal(
    this.http.get<User[]>('/api/users'),
    { initialValue: [] }
  );
}

4. 인터셉터 사용

import { HttpInterceptorFn } from '@angular/common/http';

export const authInterceptor: HttpInterceptorFn = (req, next) => {
  const authReq = req.clone({
    headers: req.headers.set('Authorization', 'Bearer token')
  });
  return next(authReq);
};

// 애플리케이션 구성
bootstrapApplication(AppComponent, {
  providers: [
    provideHttpClient(
      withInterceptors([authInterceptor]),
      withFetch()  // fetch API 사용
    )
  ]
});

주요 API 참조

API설명
resource()신호 기반 비동기 리소스 로더
httpResource()HTTP 특화 리소스 로더
HttpClientObservable 기반 HTTP 클라이언트
HttpInterceptorFn함수형 인터셉터
provideHttpClient()HTTP 클라이언트 구성 함수

모범 사례

  • 가능하면 httpResource()를 우선 사용하세요.
  • 상태 관리를 위해 isLoading, error, value 신호를 활용하세요.
  • 타입 안전성을 위해 제네릭 타입을 명시하세요.
  • 인터셉터는 함수형 패턴(HttpInterceptorFn)을 사용하세요.
  • 성능 향상을 위해 withFetch()를 활성화하세요.

참고 자료

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

analogjs/angular-component

Create modern Angular standalone components following v20+ best practices. Use for building UI components with signal-based inputs/outputs, OnPush change detection, host bindings, content projection, and lifecycle hooks. Triggers on component creation, refactoring class-based inputs to signals, adding host bindings, or implementing accessible interactive components.

analogjs/angular-di

Implement dependency injection in Angular v20+ using inject(), injection tokens, and provider configuration. Use for service architecture, providing dependencies at different levels, creating injectable tokens, and managing singleton vs scoped services. Triggers on service creation, configuring providers, using injection tokens, or understanding DI hierarchy.

analogjs/angular-directives

Create custom directives in Angular v20+ for DOM manipulation and behavior extension. Use for attribute directives that modify element behavior/appearance, structural directives for portals/overlays, and host directives for composition. Triggers on creating reusable DOM behaviors, extending element functionality, or composing behaviors across components. Note - use native @if/@for/@switch for control flow, not custom structural directives.

analogjs/angular-forms

Build signal-based forms in Angular v21+ using the new Signal Forms API. Use for form creation with automatic two-way binding, schema-based validation, field state management, and dynamic forms. Triggers on form implementation, adding validation, creating multi-step forms, or building forms with conditional fields. Signal Forms are experimental but recommended for new Angular projects. Don't use for template-driven forms without signals or third-party form libraries like Formly or ngx-formly.

analogjs/angular-routing

Implement routing in Angular v20+ applications with lazy loading, functional guards, resolvers, and route parameters. Use for navigation setup, protected routes, route-based data loading, and nested routing. Triggers on route configuration, adding authentication guards, implementing lazy loading, or reading route parameters with signals.

analogjs/angular-signals

Implement signal-based reactive state management in Angular v20+. Use for creating reactive state with signal(), derived state with computed(), dependent state with linkedSignal(), and side effects with effect(). Triggers on state management questions, converting from BehaviorSubject/Observable patterns to signals, or implementing reactive data flows.

analogjs/angular-ssr

Implement server-side rendering and hydration in Angular v20+ using @angular/ssr. Use for SSR setup, hydration strategies, prerendering static pages, and handling browser-only APIs. Triggers on SSR configuration, fixing hydration mismatches, prerendering routes, or making code SSR-compatible.

analogjs/angular-testing

Write unit and integration tests for Angular v20+ applications using Vitest or Jasmine with TestBed and modern testing patterns. Use for testing components with signals, OnPush change detection, services with inject(), and HTTP interactions. Triggers on test creation, testing signal-based components, mocking dependencies, or setting up test infrastructure. Don't use for E2E testing with Cypress or Playwright, or for testing non-Angular JavaScript/TypeScript code.

analogjs/angular-tooling

Use Angular CLI and development tools effectively in Angular v20+ projects. Use for project setup, code generation, building, testing, and configuration. Triggers on creating new projects, generating components/services/modules, configuring builds, running tests, or optimizing production builds. Don't use for Nx workspace commands, custom Webpack configurations, or non-Angular CLI build systems like Vite standalone or esbuild direct usage.

관련 스킬