A fast, elegant and standalone HTTP client.
You can install the package using npm, pnpm, yarn or bun.
npm install blink-http
# or
pnpm add blink-http
# or
yarn add blink-http
# or
bun install blink-httpimport { BlinkClient } from 'blink-http';
const blink = new BlinkClient({
baseURL: 'https://jsonplaceholder.typicode.com', // is optional
timeout: 10000, // is optional
userAgent: 'custom-user-agent' // is optional
});
const response = await blink.get('/posts/1');
console.log(await response.json()); // return response as JSONimport { BlinkClient } from 'blink-http';
const blink = new BlinkClient({
timeout: 10000, // is optional
userAgent: 'custom-user-agent' // is optional
});
const response = await blink.get('https://jsonplaceholder.typicode.com/posts/1');
console.log(await response.json()); // return response as JSON-
getget(url: string, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
postpost(url: string, body: any, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
putput(url: string, body: any, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
deletedelete(url: string, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
patchpatch(url: string, body: any, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
headhead(url: string, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
optionsoptions(url: string, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
-
tracetrace(url: string, options?: Omit<RequestInit, "body" | "method">, queryParams?: Record<string, string>, onProgress?: (event: ProgressEvent) => void): Promise<Response>
const response = await blink.get('https://jsonplaceholder.typicode.com/posts/1');
console.log(response.json());const response = await blink.post('https://jsonplaceholder.typicode.com/posts', { title: 'foo', body: 'bar', userId: 1 });
console.log(response.json());Please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.