0.1.0 • Published 8 months ago
@earthfly/axios-ex v0.1.0
AxiosEX
AxiosEX is an extended utility library built on top of Axios, designed to simplify HTTP requests and enhance functionality for modern web applications.
Features
- Simplified API for common HTTP operations.
- Enhanced error handling and response parsing.
- Support for request interceptors and custom configurations.
Installation
npm install axios-exUsage
Basic Example
import { createRetryInstance } from "axios-ex";
createRetryInstance(
{ retries: 5 },
{
baseURL: "https://api.example.com",
timeout: 5000,
}
)
.get("/api/example")
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error("Error:", error);
});Custom Configuration
import { withRetry } from "axios-ex";
const client = axios.create({
baseURL: "https://api.example.com",
timeout: 5000,
});
withRetry(client, { retries: 5 });
client
.post("/login", { username: "user", password: "pass" })
.then(response => {
console.log("Login successful:", response.data);
})
.catch(error => {
console.error("Login failed:", error);
});License
This project is licensed under the MIT License.
0.1.0
8 months ago