Xior is a lightweight HTTP request library based on the native fetch API, designed to feel familiar for those used to axios. It offers an array of features including support for plugins and a similar API, while ensuring excellent performance and strong type safety. Ideal for modern web applications.
xior is a lightweight HTTP request library primarily built upon the fetch API, designed to offer developers a plugin-supported environment with an API that closely resembles axios. This library excels in simplifying HTTP operations while incorporating advanced features for enhancing performance and control.
axios with methods such as axios.create, axios.interceptors, and supports .get, .post, .put, .patch, .delete, .head, and .options requests.To begin utilizing xior, you can simply import it into your project. Here is a brief example of how to instantiate a xior instance:
import xior from 'xior';
const xiorInstance = xior.create({
baseURL: 'https://api.example.com/',
headers: {
'Content-Type': 'application/json'
}
});
Performing a GET request is seamless:
async function fetchData() {
const { data } = await xiorInstance.get('/endpoint');
console.log(data);
}
POST requests are similarly straightforward:
async function postData() {
const response = await xiorInstance.post('/endpoint', { key: 'value' });
console.log(response.data);
}
The true strength of xior lies in its modular architecture through plugins:
xior is designed to provide an organized and efficient way to manage HTTP requests while minimizing the complexity associated with managing asynchronous operations. Its plugin system allows for rapid adaptability to varying project needs and requirements.
No comments yet.
Sign in to be the first to comment.