@chatbotkit/fetch
v1.8.0
Published
Isomorphic implenetation for fetch specifically designed for @chatbotkit/sdk.
Downloads
173
Readme
ChatBotKit Fetch SDK
The ChatBotKit SDK for Fetch offers an isomorphic implementation of the standard fetch browser function, enriched with several helper methods. This versatile SDK is compatible with various environments, including AWS Lambda, Vercel Serverless and Edge, Cloudflare Workers, standard web browsers, and more, making it a flexible choice for diverse projects.
Getting Started
To begin using the ChatBotKit Fetch SDK, follow these steps:
Installation: Add the SDK to your project using npm:
npm install @chatbotkit/fetch
Usage: The SDK can be used in any environment, ensuring a consistent fetch functionality across platforms. Here’s an example of how to use it:
import fetch, { withRetry, withTimeout } from '@chatbotkit/fetch' // Enhance fetch with retry and timeout capabilities const fetchPlusPlus = withRetry(withTimeout(fetch)) async function doWork() { const response = await fetchPlusPlus('https://your-api-url.com', { timeout: 30000, // Timeout in milliseconds retries: 5, // Number of retry attempts retryDelay: 200, // Delay between retries in milliseconds }) // Handle the response // ... }
This code snippet demonstrates how to import and use the enhanced fetch function, providing robust error handling and timeout management for network requests.
Documentation
For comprehensive information about the ChatBotKit Fetch SDK, including detailed documentation on its functionalities, helper methods, and configuration options, please visit our type documentation page.
Contributing
If you find a bug or would like to contribute to the ChatBotKit SDK, please open an issue or submit a pull request on the official GitHub repository.