angular-http

Implement HTTP data fetching in Angular using httpResource, resource, and HttpClient.

Updated Aug 10, 2025
One-click install
npx skills add https://github.com/afonsoft/ai-studio-workspace --skill angular-http-afonsoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: angular-http
Source: https://github.com/afonsoft/ai-studio-workspace/tree/main/agents/skills/angular-http
Command: npx skills add https://github.com/afonsoft/ai-studio-workspace --skill angular-http-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Angular developers need consistent patterns for fetching API data, managing loading and error states, and migrating from Observable-based HTTP to signal-based reactivity in Angular v20+. ## Core Features & Use Cases - Signal-Based HTTP: Use httpResource() and resource() for reactive data fetching that automatically refetches when signal inputs change, with built-in loading, error, and status states. - Traditional HttpClient: Full coverage of GET, POST, PUT, PATCH, DELETE methods with headers, params, and Observable-to-signal conversion via toSignal. - Interceptors & Error Handling: Functional interceptors for auth tokens, logging, and global error handling, plus retry and cancellation patterns. - Use Case: Build a paginated user list where changing the page signal automatically triggers a new API request, displays a spinner while loading, and shows a retry button on failure. ## Quick Start Ask the AI to create an Angular component that fetches a user from an API using httpResource with loading and error states.

Frequently Asked Questions about angular-http

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch API data in Angular using signals?▼

Use httpResource() from @angular/common/http to create a reactive HTTP request bound to signals. It exposes value(), isLoading(), error(), and status() signals, and automatically refetches when the reactive inputs in its request function change.

What is the difference between httpResource and HttpClient in Angular?▼

httpResource wraps HttpClient with signal-based state management, giving you loading, error, and reload handling declaratively. HttpClient returns Observables and suits complex operator chains or one-off mutations like POST and DELETE calls.

How do I add an auth token to Angular HTTP requests?▼

Create a functional interceptor implementing HttpInterceptorFn that clones the request with an Authorization header, then register it via provideHttpClient(withInterceptors([authInterceptor])) in your application config.

How do I cancel an HTTP request when search input changes in Angular?▼

The resource() API passes an abortSignal to its loader, which automatically cancels the previous fetch when params change. With HttpClient, unsubscribe from the prior subscription or use switchMap with debounceTime for debounced search.

How do I test Angular components that use httpResource?▼

Provide provideHttpClientTesting() in TestBed, inject HttpTestingController, and use expectOne() to match the request URL, then flush mock data. Assert on the resource's value() signal after flushing the response.

When should I use resource() instead of httpResource() in Angular?▼

Use resource() for non-HTTP async operations or custom fetch logic where you control the loader function, such as direct fetch calls or computed data. Use httpResource when you want HttpClient-backed requests with minimal setup.