TypeScript HTTP Client
raw JSON → 0.10.5 verified Sat Apr 25 auth: no javascript maintenance
A lightweight Promise-based HTTP client for TypeScript with a filter chain architecture, version 0.10.5. Released infrequently (last update 2020). Differentiates from axios/fetch by offering a middleware-like filter system for request/response transformation, caching, or logging. Ships TypeScript types. Supports typed responses via generics. Not actively maintained; consider alternatives like ky or axios for modern apps.
Common errors
error TypeError: client.execute is not a function ↓
cause Old API: newClient() was renamed to newHttpClient() in v0.10.
fix
Use newHttpClient() to create the client instance.
error Error: Filter must call filterChain.doFilter ↓
cause A filter's doFilter did not invoke filterChain.doFilter() causing infinite wait.
fix
Add 'const response = await filterChain.doFilter(call); return response;' in each filter.
error Property 'body' does not exist on type 'Response<U>' ↓
cause Misunderstanding of Response type: body property exists but may be typed incorrectly.
fix
Ensure generic parameter matches expected response body type.
Warnings
gotcha Filter chain: Filters must call filterChain.doFilter() or the request hangs. ↓
fix Ensure each filter's doFilter method awaits or returns filterChain.doFilter(call).
breaking Version 0.10.x renamed newClient() to newHttpClient(). ↓
fix Use newHttpClient() instead of newClient().
deprecated Package not updated since 2020; may have unpatched security issues. ↓
fix Consider migrating to a maintained alternative like ky or axios.
gotcha The Request constructor's responseType defaults to 'json'; set to 'text' for string responses. ↓
fix Explicitly set { responseType: 'text' } for non-JSON responses.
Install
npm install typescript-http-client yarn add typescript-http-client pnpm add typescript-http-client Imports
- newHttpClient wrong
import newHttpClient from 'typescript-http-client'correctimport { newHttpClient } from 'typescript-http-client' - Request wrong
const Request = require('typescript-http-client').Requestcorrectimport { Request } from 'typescript-http-client' - Response
import { Response } from 'typescript-http-client' - Filter
import { Filter } from 'typescript-http-client' - FilterChain
import { FilterChain } from 'typescript-http-client'
Quickstart
import { Request, newHttpClient } from 'typescript-http-client';
const client = newHttpClient();
const request = new Request('https://jsonplaceholder.typicode.com/todos/1', { responseType: 'text' });
client.execute<string>(request).then(response => {
console.log(response);
}).catch(err => {
console.error(err);
});