Exported Utilities & Helpers
Standalone helper functions and managers exported by react-native-fetch-client for custom networking logic.
URL & Link Utilities
utils.ts
typescript
import {
buildUrl,
interpolatePath,
isAbsoluteUrl,
parseSseStream,
createPaginateHelper,
parseNextLinkHeader,
createMockAdapter,
createOfflineQueue,
MemoryStorageAdapter,
} from 'react-native-fetch-client';
// 1. Path parameter interpolation:
// Returns: "/users/42/posts/99"
const url = interpolatePath('/users/:userId/posts/:postId', {
userId: '42',
postId: '99',
});
// 2. RFC 3986 URL builder with query params:
// Returns: "https://api.example.com/search?q=fetch&sort=desc"
const fullUrl = buildUrl('https://api.example.com/search', {
q: 'fetch',
sort: 'desc',
});
// 3. Absolute URL checker:
console.log(isAbsoluteUrl('https://example.com')); // true
console.log(isAbsoluteUrl('/relative/path')); // false
// 4. RFC 5988 Link Header Parser:
// Returns: "https://api.example.com/items?page=2"
const nextUrl = parseNextLinkHeader('<https://api.example.com/items?page=2>; rel="next"');