Trembita is a small, efficient TypeScript ESM client designed for seamless interaction with third-party JSON APIs. Leveraging the fetch API with a strict Result-based error handling, it ensures reliable API calls without the baggage of legacy dependencies. Ideal for developers seeking a straightforward yet powerful solution.
Trembita is a lightweight and efficient TypeScript HTTP client designed for consuming third-party JSON APIs. Built on the native fetch API, it provides a functional error handling mechanism through a Result<T, E> API structure, ensuring robust interactions with external services while eliminating the clutter of legacy dependencies.
createTrembita() which returns an API featuring only essential functions, promoting a cleaner coding experience..d.ts files and source maps while ensuring tree-shakability.Basic Setup for API Interaction:
import { createTrembita, HTTP_OK } from 'trembita';
const api = createTrembita({ endpoint: 'https://api.example.com/v1' });
if (!api.ok) throw new Error('Invalid endpoint');
const json = await api.value.request({
path: '/resource',
expectedCodes: [HTTP_OK]
});
if (!json.ok) {
console.error(json.error.kind);
}
Choose your path:
Trembita streamlines interactions with JSON APIs through a type-safe, minimalistic, and efficient approach that emphasizes clarity and usability, making it an excellent choice for developers looking to elevate their HTTP request handling in TypeScript.
No comments yet.
Sign in to be the first to comment.