http-client-patterns

Implement Axios HTTP clients with error mapping, timeouts, retries, and safe shutdown.

6|Updated Feb 20, 2025
One-click install
npx skills add https://github.com/zerobias-org/module --skill http-client-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: http-client-patterns
Source: https://github.com/zerobias-org/module/tree/main/.claude/skills/http-client-patterns
Command: npx skills add https://github.com/zerobias-org/module --skill http-client-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a structured blueprint for implementing robust HTTP client patterns (using Axios or similar) that ensure reliable API communication, proper error mapping, and safe operational behavior.

Core Features & Use Cases

  • Centralized error handling that maps API errors to well-defined core error types.
  • Configurable Axios client with sensible timeouts, headers, and base URL management.
  • Interceptors for authentication, tracing, and request/response logging without exposing credentials.
  • Retry logic with exponential backoff for transient failures only.
  • Real API connectivity checks to validate credentials and API availability.

Quick Start

Use Axios to implement a durable HTTP client with real API calls, error mapping, and automatic retries.

Frequently Asked Questions about http-client-patterns

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

FAQPage Schema
How do I implement retry logic with exponential backoff for axios HTTP requests?

Retry logic with exponential backoff for axios requests is implemented by configuring automatic retries that trigger only for transient failures, ensuring safe recovery without overwhelming the target API. The pattern applies exponential delays between retry attempts to handle temporary network or service disruptions effectively.

What is the best way to handle API errors in axios and map them to core error types?

Handling API errors in axios is best achieved through centralized error handling that maps raw API error responses to well-defined core error types. This approach ensures safe error messages are returned to the application, preventing sensitive data exposure while maintaining consistent error categorization across microservices.

How do I configure per-request timeouts in axios for microservice integrations?

Per-request timeouts in axios are configured through a durable HTTP client setup that applies sensible timeout boundaries alongside base URL and header management. This ensures resilient data fetching across microservices by preventing indefinite hanging requests and enabling safe resource cleanup during shutdown.

Can I use axios interceptors for authentication and request logging without exposing credentials?

Axios interceptors can be used for authentication, tracing, and request or response logging without exposing credentials by applying secure interceptor patterns within the HTTP client configuration. This ensures sensitive authentication data is injected safely into requests while logging mechanisms filter out protected information.

How do I safely shut down an HTTP client and clean up resources during application termination?

Safe shutdown and resource cleanup for an HTTP client during application termination are handled by implementing proper connection closure patterns within the axios client lifecycle. This guarantees that pending API requests are resolved or canceled securely, preventing resource leaks and abrupt disconnections in microservice environments.