@hosterai/adapter-fetch
v1.0.0
Published
Native fetch adapter for Hoster.AI client
Downloads
88
Maintainers
Readme
@hosterai/adapter-fetch
Native fetch adapter for Hoster.AI client. Works in browsers, Node.js 18+, and edge runtimes.
Installation
npm install @hosterai/core @hosterai/adapter-fetchUsage
import { Client } from '@hosterai/core';
import { createFetchAdapter } from '@hosterai/adapter-fetch';
const client = new Client({
baseURL: 'https://api.hoster.ai',
httpAdapter: createFetchAdapter({
timeout: 30000, // optional, default 30s
})
});
client.setAccessToken('your-token');
// Now all requests use native fetch
const result = await client.execute(
client.createRequest('GET', '/users')
);Options
interface FetchAdapterOptions {
fetch?: typeof fetch; // Custom fetch implementation
timeout?: number; // Request timeout in ms (default: 30000)
headers?: Record<string, string>; // Default headers
}