Grab.js is a compact HTTP client that packs powerful features into just 5KB. Designed for developers who need speed and efficiency, Grab.js offers capabilities like circuit breakers, ETags, and request deduplication. Whether you're building a small application or a large system, Grab.js simplifies your HTTP requests.
- Lightweight: At only 5KB, Grab.js is perfect for performance-focused applications.
- Circuit Breakers: Prevents system overload by managing failed requests intelligently.
- ETags Support: Efficiently handles caching to reduce server load and speed up responses.
- Request Deduplication: Avoids duplicate requests, ensuring that your application runs smoothly.
- Promise-based API: Simplifies asynchronous programming with a clean, easy-to-use interface.
To get started with Grab.js, you can install it via npm:
npm install grab-js
Alternatively, you can download the latest release from the Releases section. Make sure to download and execute the file to set it up correctly.
Using Grab.js is straightforward. Hereβs a quick example to demonstrate how to make a simple GET request:
import Grab from 'grab-js';
const client = new Grab();
client.get('https://api.example.com/data')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error fetching data:', error);
});
You can also take advantage of the advanced features. Hereβs how to use circuit breakers:
const client = new Grab({
circuitBreaker: {
failureThreshold: 5,
timeout: 3000,
}
});
client.get('https://api.example.com/data')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error fetching data:', error);
});
Creates a new Grab instance.
- options: An object to configure the client.
Makes a GET request to the specified URL.
- url: The URL to fetch.
- options: Additional options for the request.
Makes a POST request to the specified URL.
- url: The URL to send data to.
- data: The data to send.
- options: Additional options for the request.
We welcome contributions to Grab.js! If you'd like to help out, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch and submit a pull request.
Please ensure your code follows the project's style guidelines and includes appropriate tests.
Grab.js is licensed under the MIT License. See the LICENSE file for more details.
For support, please check the Releases section for the latest updates and fixes. You can also open an issue in the repository if you encounter any problems.
Feel free to explore the features of Grab.js and see how it can enhance your HTTP requests. For further information, visit the Releases section to stay updated on the latest changes and improvements.