fsfetch
v1.0.6
Published
Simple tool to make fast fetchs
Downloads
1
Readme
⚡ FsFetch
FastFetch is a super fast and optimized HTTP client for Node.js. It provides a simple and intuitive API to make HTTP requests with ease, inspired by the simplicity of Axios.
Features
- 🚀 Super Fast: Optimized for speed and performance.
- ⚙️ Simple API: Easy to use, similar to Axios.
- 🔒 Configurable: Custom headers, timeouts, and more.
- 🌐 Supports All HTTP Methods: GET, POST, PUT, DELETE, PATCH.
Available Methods
get(url: string, config?: HTTPRequestConfig): Promise<HTTPResponse<T>>
post(url: string, data: any, config?: HTTPRequestConfig): Promise<HTTPResponse<T>>
put(url: string, data: any, config?: HTTPRequestConfig): Promise<HTTPResponse<T>>
delete(url: string, config?: HTTPRequestConfig): Promise<HTTPResponse<T>>
patch(url: string, data: any, config?: HTTPRequestConfig): Promise<HTTPResponse<T>>
Configuration Options
headers
: Custom HTTP headers to send with the request.timeout
: Request timeout in milliseconds.
Example Usage
GET Request
Making a GET request:
import FastFetch from 'fsfetch';
FastFetch.get('http://api.example.com/data')
.then(response => console.log('GET response:', response.data))
.catch(error => console.error('GET error:', error));
POST Request
Making a POST request with custom headers and timeout:
import FastFetch from 'fastfetch';
FastFetch.post('http://api.example.com/data', { key: 'value' }, {
headers: {
'Custom-Header': 'CustomValue',
'Authorization': 'Bearer your_token'
},
timeout: 5000 // 5 seconds
})
.then(response => console.log('POST response:', response.data))
.catch(error => console.error('POST error:', error));