Production Best Practices
Practical guidance for choosing request policies and handling sensitive request data.
1. Authorization Header Redaction
The resolved request configuration redacts the Authorization header and any configured auth header before it is attached to a response or error. This does not sanitize arbitrary request bodies, custom secret headers, or data your application logs separately. Review those values before sending diagnostics to a logging service:
security.ts
typescript
import { createClient } from 'react-native-fetch-client';
const api = createClient({
baseURL: 'https://api.example.com',
bearerToken: 'example-token',
});
const response = await api.get('/secret-user');
// Authorization values in the resolved request config are redacted.
console.log(response.config.headers.authorization); // '[REDACTED]'2. Choose Policies for Your Workload
Enable caching, retries, deduplication, or a concurrency limit only when their behavior matches your API and freshness requirements. Test the chosen values with your own endpoints and runtime:
- Deduplication: Matching eligible in-flight requests can share a network operation.
- Cache: Select a TTL and strategy that fit how fresh the data needs to be.
- Concurrency: Set
maxConcurrentRequeststo cap active requests when that helps your application.