@beyond-js/http-suite
v0.1.1
Published
A package built to simplify HTTP requests in modern web projects. It handles everything from basic API calls to data streaming, making it easy to work with web services. Designed to be intuitive and flexible, it helps developers manage web communication w
Readme
@beyond-js/http-suite
Introduction
@beyond-js/http-suite is a comprehensive JavaScript package designed to simplify interactions with APIs. The core of
this package is the Api object, which provides an easy-to-use interface for making HTTP requests to an API.
Installation
To install @beyond-js/http-suite, run the following command in your project directory:
npm install @beyond-js/http-suiteUsage
Creating an Instance of Api
Start by importing the Api class and creating an instance:
import { Api } from '@beyond-js/http-suite/api';
const baseUrl = 'https://your-api-url.com';
const api = new Api(baseUrl);Setting Authentication
If your API requires authentication, use the bearer method to set the token:
api.bearer('your-auth-token');Making Requests
@beyond-js/http-suite supports various HTTP methods like GET, POST, PUT, DELETE, and custom stream methods.
GET Request
const response = await api.get('/path/url');POST Request
const postData = { key: 'value' };
const postResponse = await api.post('/path/post-url', postData);PUT Request
const putData = { key: 'updated-value' };
const putResponse = await api.put('/path/put-url', putData);DELETE Request
const deleteResponse = await api.delete('/path/delete-url');Stream Request
const streamResponse = await api.stream('/path/stream-url');Features
- Easy API interactions: Simplifies the process of making HTTP requests.
- Bearer token authentication: Easily set authentication tokens for API requests.
- Supports multiple HTTP methods:
GET,POST,PUT,DELETE, and streaming. - Reactive model integration: Utilizes
ReactiveModelfor state management in API interactions. - Stream processing: Offers a unique way to handle streaming data with custom actions and events.
Contributing
Contributions are welcome! Please submit a pull request or an issue on the project's GitHub page.
License
@beyond-js/http-suite is licensed under MIT License.
Please ensure to modify the example code and descriptions to suit your specific API's needs and structure.
