Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahmudunnabikajal/datatable-axios
Datatable Axios is a simple and convenient npm package that helps you make GET, POST, and PUT requests with ease, while handling search parameters and pagination seamlessly for ssr datatable. It's built on top of the popular Axios library, making it reliable and efficient for your data fetching needs.
https://github.com/mahmudunnabikajal/datatable-axios
datatable datatable-api datatable-axios datatable-serverside datatable-vue datatables-library datatables-plugin datatables-server-side-scripting vue-datatable
Last synced: 11 days ago
JSON representation
Datatable Axios is a simple and convenient npm package that helps you make GET, POST, and PUT requests with ease, while handling search parameters and pagination seamlessly for ssr datatable. It's built on top of the popular Axios library, making it reliable and efficient for your data fetching needs.
- Host: GitHub
- URL: https://github.com/mahmudunnabikajal/datatable-axios
- Owner: mahmudunnabikajal
- License: mit
- Created: 2023-08-15T10:40:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-20T09:18:19.000Z (over 1 year ago)
- Last Synced: 2024-12-19T18:09:06.079Z (28 days ago)
- Topics: datatable, datatable-api, datatable-axios, datatable-serverside, datatable-vue, datatables-library, datatables-plugin, datatables-server-side-scripting, vue-datatable
- Language: JavaScript
- Homepage: https://mahmudunnabikajal.github.io/datatable-axios/
- Size: 196 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Datatable Axios
[![mahmudunnabikajal - datatable-axios](https://img.shields.io/static/v1?label=mahmudunnabikajal&message=datatable-axios&color=blue&logo=github)](https://github.com/mahmudunnabikajal/datatable-axios "Go to GitHub repo")
[![Latest Stable Version](https://img.shields.io/npm/v/datatable-axios.svg)](https://www.npmjs.com/package/datatable-axios)
[![NPM Downloads](https://img.shields.io/npm/dt/datatable-axios.svg)](https://www.npmjs.com/package/datatable-axios)
[![License](https://img.shields.io/badge/License-MIT-blue)](#license)
[![Documentation](https://img.shields.io/badge/Documentation-blue)](https://mahmudunnabikajal.github.io/datatable-axios/ "Go to project documentation")Datatable Axios is a simple and convenient npm package that helps you make GET, POST, and PUT requests with ease, while handling search parameters and pagination seamlessly. It's built on top of the popular Axios library, making it reliable and efficient for your data fetching needs.
# Installation
You can install Datatable Axios using npm:```bash
npm install datatable-axios
```
# Why Datatable Axios?
Simplify your `HTTP calls without repetition`. Say goodbye to repeating steps for every datatable request!- **`Cons:`** Without using the library, you can achieve the same functionality in Axios which ***isn't readable & reusable***.
```js
const response = await axios.get('http://example.com/api/v1/products?page=2&paginate=25&search=we');
console.log(response.data);
```
- **`Pros:`** After using this library, you can achieve the same functionality of Axios in a ***readable & reusable way***
```js
const response = await datatable.get('products');
console.log(response.data);
```
# Usage
To get started with Datatable Axios, follow these simple steps:- use global axios plugin setup in `axios.js` (optional)
``` js
import axios from "axios"// Make the axios library globally available on the window object
window.axios = axios
// Set your base API URL for seamless requests
window.axios.defaults.baseURL = "http://example.com/api/v1/"// Other configuration here
```- Import the package at the top of your JavaScript file:
```js
import datatable from 'datatable-axios'
```
- Initialize an instance of the Datatable class:```js
const datatable = new Datatable();
```
# Use of API URL:- When you have a global `axios.js` configuration setting with baseURL, simplify calls API by using just the path:
```js
const response = await datatable.get('products');
console.log(response.data);
```
- If you're not utilizing a global `axios.js` configuration for with baseURL, include the full URL when making API calls:
```js
const response = await datatable.get('http://example.com/api/v1/products');
console.log(response.data);
```
# Use of HTTP requests:- Perform a GET request:
```js
const response = await datatable.get('url or path');
console.log(response.data); // Display the fetched data
```
- Perform a POST request:
```js
const response = await datatable.post('url or path');
console.log(response.data); // Display the response data
```
- Perform a PUT request:
```js
const response = await datatable.put('url or path');
console.log(response.data); // Display the updated data
```
# Example of HTTP call:
- Example 1 :
```js
datatable.get('http://example.com/api/v1/products')
.then(response => {
console.log("Data fetched successfully:", response.data);
})
.catch(error => {
console.error("An error occurred:", error);
});
```
- Example 2 :
```js
try {
const response = await datatable.get('/api/v1/products');
console.log("Data fetched successfully:", response.data);
} catch (error) {
console.error("An error occurred:", error);
}
```
**`Note:`** Similar usage for POST and PUT requests
# Contributing
We welcome contributions to enhance Datatable Axios! Feel free to open issues for bug reports or feature requests. If you'd like to contribute code, please fork the repository, make your changes, and submit a pull request.
# License
Released under [MIT License](LICENSE) by [@mahmudunnabikajal](https://github.com/mahmudunnabikajal).
# Author
Mahmudun Nabi Kajal
Contact: [Linkedin](https://www.linkedin.com/in/mahmudun-nabi-kajal/), [GitHub](https://github.com/mahmudunnabikajal), [Gmail](mailto:mahmudunnabikajal), [Website](http://mahmudunnabikajal.com/)Feel free to reach out to me for any questions or feedback! I hope Datatable Axios simplifies your data fetching process for your datatable.