UNPKG

@nofrills/http

Version:

Provides a simple, Fetch-based HTTP client.

15 lines (14 loc) 768 B
import { RequestInit } from 'node-fetch'; import { Lincoln } from './Logger'; export declare abstract class HTTP { protected readonly log: Lincoln; delete<TResponse>(url: string): Promise<TResponse>; get<TResponse>(url: string): Promise<TResponse>; head<TResponse>(url: string): Promise<TResponse>; patch<TRequest, TResponse>(url: string, body: TRequest): Promise<TResponse>; post<TRequest, TResponse>(url: string, body: TRequest): Promise<TResponse>; put<TRequest, TResponse>(url: string, body: TRequest): Promise<TResponse>; protected abstract readonly name: string; protected abstract request<TRequest>(body?: TRequest): Promise<RequestInit>; protected send<T>(url: string, init: RequestInit, method?: string): Promise<T>; }