1.2.2 • Published 10 months ago
whizz v1.2.2
Installation
To install Whizz:
npm install whizz
# or
yarn add whizz
# or
pnpm install whizz
Usage
Here are some examples of how to use Whizz:
GET Request
import whizz from 'whizz';
async function fetchData() {
const response = await whizz.get('https://jsonplaceholder.typicode.com/posts/1', { secure: true, timeout: 2000 });
const data = response.json();
console.log(data);
}
fetchData();
POST Request
import whizz from 'whizz';
async function postData() {
const response = await whizz.post('https://jsonplaceholder.typicode.com/posts', {
title: 'foo',
body: 'bar',
userId: 1,
}, { secure: false });
const data = response.json();
console.log(data);
}
postData();
API Documentation
get(url: string, options?: RequestOptions): Promise<Response>
Makes a GET request to the specified URL.
post(url: string, data: any, options?: RequestOptions): Promise<Response>
Makes a POST request to the specified URL with the provided data.
put(url: string, data: any, options?: RequestOptions): Promise<Response>
Makes a PUT request to the specified URL with the provided data.
delete(url: string, options?: RequestOptions): Promise<Response>
Makes a DELETE request to the specified URL.
patch(url: string, options?: RequestOptions): Promise<Response>
Makes a PATCH request to the specified URL.
head(url: string, options?: RequestOptions): Promise<Response>
Makes a HEAD request to the specified URL.
options(url: string, options?: RequestOptions): Promise<Response>
Makes an OPTIONS request to the specified URL.
trace(url: string, options?: RequestOptions): Promise<Response>
Makes a TRACE request to the specified URL.
connect(url: string, options?: RequestOptions): Promise<Response>
Makes a CONNECT request to the specified URL.
Contributing
Contributions are welcome! Please read the contributing guidelines for more information.
License
This project is licensed under the MIT License. See the LICENSE file for details.