datatable-axios 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/Readme.md +137 -1
- package/dist/datatable-axios.cjs.js +48 -17
- package/dist/datatable-axios.esm.js +48 -17
- package/dist/datatable-axios.umd.js +48 -17
- package/package.json +59 -59
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Mahmudun Nabi Kajal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Readme.md
CHANGED
|
@@ -1 +1,137 @@
|
|
|
1
|
-
# Datatable Axios
|
|
1
|
+
# Datatable Axios
|
|
2
|
+
[](https://github.com/mahmudunnabikajal/datatable-axios "Go to GitHub repo")
|
|
3
|
+
[](https://www.npmjs.com/package/datatable-axios)
|
|
4
|
+
[](https://www.npmjs.com/package/datatable-axios)
|
|
5
|
+
[](#license)
|
|
6
|
+
<!-- [](./docs/index.html "Go to project documentation") -->
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Installation
|
|
13
|
+
You can install Datatable Axios using npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install datatable-axios
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
# Why Datatable Axios?
|
|
20
|
+
Simplify your `HTTP calls without repetition`. Say goodbye to repeating steps for every datatable request!
|
|
21
|
+
|
|
22
|
+
- **`Cons:`** Without using the library, you can achieve the same functionality in Axios which `isn't readable & reusable`.
|
|
23
|
+
```js
|
|
24
|
+
const response = await axios.get('http://example.com/api/v1/products?page=2&paginate=25&search=we');
|
|
25
|
+
console.log(response.data);
|
|
26
|
+
```
|
|
27
|
+
- **`Pros:`** After using this library, you can achieve the same functionality of Axios in a `readable & reusable way`
|
|
28
|
+
```js
|
|
29
|
+
const response = await datatable.get('products');
|
|
30
|
+
console.log(response.data);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# Usage
|
|
34
|
+
To get started with Datatable Axios, follow these simple steps:
|
|
35
|
+
|
|
36
|
+
- use global axios plugin setup in `axios.js` (optional)
|
|
37
|
+
``` js
|
|
38
|
+
import axios from "axios"
|
|
39
|
+
|
|
40
|
+
// Make the axios library globally available on the window object
|
|
41
|
+
window.axios = axios
|
|
42
|
+
// Set your base API URL for seamless requests
|
|
43
|
+
window.axios.defaults.baseURL = "http://example.com/api/v1/"
|
|
44
|
+
|
|
45
|
+
// Other configuration here
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- Import the package at the top of your JavaScript file:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import datatable from 'datatable-axios'
|
|
52
|
+
```
|
|
53
|
+
- Initialize an instance of the Datatable class:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const datatable = new Datatable();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
# Use of API URL:
|
|
60
|
+
|
|
61
|
+
- When you have a global `axios.js` configuration setting with baseURL, simplify calls API by using just the path:
|
|
62
|
+
```js
|
|
63
|
+
const response = await datatable.get('products');
|
|
64
|
+
console.log(response.data);
|
|
65
|
+
```
|
|
66
|
+
- If you're not utilizing a global `axios.js` configuration for with baseURL, include the full URL when making API calls:
|
|
67
|
+
```js
|
|
68
|
+
const response = await datatable.get('http://example.com/api/v1/products');
|
|
69
|
+
console.log(response.data);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
# Use of HTTP requests:
|
|
73
|
+
|
|
74
|
+
- Perform a GET request:
|
|
75
|
+
```js
|
|
76
|
+
const response = await datatable.get('url or path');
|
|
77
|
+
console.log(response.data); // Display the fetched data
|
|
78
|
+
```
|
|
79
|
+
- Perform a POST request:
|
|
80
|
+
```js
|
|
81
|
+
const response = await datatable.post('url or path');
|
|
82
|
+
console.log(response.data); // Display the response data
|
|
83
|
+
```
|
|
84
|
+
- Perform a PUT request:
|
|
85
|
+
```js
|
|
86
|
+
const response = await datatable.put('url or path');
|
|
87
|
+
console.log(response.data); // Display the updated data
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
# Example of HTTP call:
|
|
91
|
+
- Example 1 :
|
|
92
|
+
```js
|
|
93
|
+
datatable.get('http://example.com/api/v1/products')
|
|
94
|
+
.then(response => {
|
|
95
|
+
console.log("Data fetched successfully:", response.data);
|
|
96
|
+
})
|
|
97
|
+
.catch(error => {
|
|
98
|
+
console.error("An error occurred:", error);
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
- Example 2 :
|
|
102
|
+
```js
|
|
103
|
+
try {
|
|
104
|
+
const response = await datatable.get('/api/v1/products');
|
|
105
|
+
console.log("Data fetched successfully:", response.data);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("An error occurred:", error);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
**`Note:`** Similar usage for POST and PUT requests
|
|
111
|
+
<!-- # Advanced Usage
|
|
112
|
+
You can also pass search parameters, pagination, and search queries to your requests:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
// Append search parameters to the URL
|
|
116
|
+
const response = await datatable.get('https://api.example.com/data', {
|
|
117
|
+
page: 1,
|
|
118
|
+
paginate: 10,
|
|
119
|
+
search: 'keyword',
|
|
120
|
+
});
|
|
121
|
+
console.log(response.data);
|
|
122
|
+
``` -->
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# Contributing
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# License
|
|
130
|
+
Released under [MIT License](LICENSE) by [@mahmudunnabikajal](https://github.com/mahmudunnabikajal).
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# Author
|
|
134
|
+
Mahmudun Nabi Kajal<br />
|
|
135
|
+
Contact: [Linkedin](https://www.linkedin.com/in/mahmudun-nabi-kajal/), [GitHub](https://github.com/mahmudunnabikajal), [Gmail](mailto:mahmudunnabikajal)
|
|
136
|
+
|
|
137
|
+
Feel free to reach out to me for any questions or feedback! I hope Datatable Axios simplifies your data fetching process for your datatable.
|
|
@@ -2,60 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
|
|
5
|
+
// Import the axios library
|
|
6
|
+
|
|
7
|
+
// Make the axios library globally available on the window object
|
|
5
8
|
window.axios = axios;
|
|
6
9
|
|
|
7
|
-
//
|
|
8
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
9
|
-
|
|
10
|
-
// Get individual query parameter values
|
|
10
|
+
// Import the axios instance from the local file "./axios"
|
|
11
11
|
|
|
12
|
+
// Parse the search parameters from the URL
|
|
13
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
12
14
|
|
|
13
15
|
class datatable {
|
|
14
16
|
constructor() {
|
|
15
|
-
|
|
16
|
-
// this.paginate = router.currentRoute.value.query.paginate
|
|
17
|
-
// this.search = router.currentRoute.value.query.search
|
|
17
|
+
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
// Method to perform a GET request
|
|
19
21
|
async get(url) {
|
|
20
|
-
//
|
|
21
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
22
|
-
// const search = router.currentRoute.value.query.search
|
|
22
|
+
// Retrieve values from search parameters
|
|
23
23
|
const page = searchParams.get('page');
|
|
24
24
|
const paginate = searchParams.get('paginate');
|
|
25
25
|
const search = searchParams.get('search');
|
|
26
26
|
|
|
27
|
+
// Return a Promise that resolves when the request completes
|
|
27
28
|
return new Promise(async (resolve) => {
|
|
28
29
|
if (!page && !paginate && !search) {
|
|
30
|
+
// If no search parameters, make a regular GET request
|
|
29
31
|
await window.axios.get(url).then(response => {
|
|
30
|
-
resolve(response);
|
|
32
|
+
resolve(response); // Resolve the Promise with the response
|
|
31
33
|
});
|
|
32
34
|
} else {
|
|
35
|
+
// If search parameters exist, append them to the URL
|
|
33
36
|
await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
34
|
-
resolve(response);
|
|
37
|
+
resolve(response); // Resolve the Promise with the response
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
})
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
// Method to perform a POST request
|
|
39
44
|
async post(url) {
|
|
40
|
-
//
|
|
41
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
42
|
-
// const search = router.currentRoute.value.query.search
|
|
45
|
+
// Retrieve values from search parameters
|
|
43
46
|
const page = searchParams.get('page');
|
|
44
47
|
const paginate = searchParams.get('paginate');
|
|
45
48
|
const search = searchParams.get('search');
|
|
46
49
|
|
|
50
|
+
// Return a Promise that resolves when the request completes
|
|
47
51
|
return new Promise(async (resolve) => {
|
|
48
52
|
if (!page && !paginate && !search) {
|
|
53
|
+
// If no search parameters, make a regular POST request
|
|
49
54
|
await window.axios.post(url).then(response => {
|
|
50
|
-
resolve(response);
|
|
55
|
+
resolve(response); // Resolve the Promise with the response
|
|
51
56
|
});
|
|
52
57
|
} else {
|
|
58
|
+
// If search parameters exist, append them to the URL
|
|
53
59
|
await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
54
|
-
resolve(response);
|
|
60
|
+
resolve(response); // Resolve the Promise with the response
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Method to perform a PUT request
|
|
67
|
+
async put(url) {
|
|
68
|
+
// Retrieve values from search parameters
|
|
69
|
+
const page = searchParams.get('page');
|
|
70
|
+
const paginate = searchParams.get('paginate');
|
|
71
|
+
const search = searchParams.get('search');
|
|
72
|
+
|
|
73
|
+
// Return a Promise that resolves when the request completes
|
|
74
|
+
return new Promise(async (resolve) => {
|
|
75
|
+
if (!page && !paginate && !search) {
|
|
76
|
+
// If no search parameters, make a regular PUT request
|
|
77
|
+
await window.axios.put(url).then(response => {
|
|
78
|
+
resolve(response); // Resolve the Promise with the response
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
// If search parameters exist, append them to the URL
|
|
82
|
+
await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
83
|
+
resolve(response); // Resolve the Promise with the response
|
|
55
84
|
});
|
|
56
85
|
}
|
|
57
86
|
})
|
|
58
87
|
}
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
// Import the "datatable" class from the local file "./datatable"
|
|
91
|
+
|
|
61
92
|
module.exports = datatable;
|
|
@@ -1,59 +1,90 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
|
|
3
|
+
// Import the axios library
|
|
4
|
+
|
|
5
|
+
// Make the axios library globally available on the window object
|
|
3
6
|
window.axios = axios;
|
|
4
7
|
|
|
5
|
-
//
|
|
6
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
7
|
-
|
|
8
|
-
// Get individual query parameter values
|
|
8
|
+
// Import the axios instance from the local file "./axios"
|
|
9
9
|
|
|
10
|
+
// Parse the search parameters from the URL
|
|
11
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
10
12
|
|
|
11
13
|
class datatable {
|
|
12
14
|
constructor() {
|
|
13
|
-
|
|
14
|
-
// this.paginate = router.currentRoute.value.query.paginate
|
|
15
|
-
// this.search = router.currentRoute.value.query.search
|
|
15
|
+
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
// Method to perform a GET request
|
|
17
19
|
async get(url) {
|
|
18
|
-
//
|
|
19
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
20
|
-
// const search = router.currentRoute.value.query.search
|
|
20
|
+
// Retrieve values from search parameters
|
|
21
21
|
const page = searchParams.get('page');
|
|
22
22
|
const paginate = searchParams.get('paginate');
|
|
23
23
|
const search = searchParams.get('search');
|
|
24
24
|
|
|
25
|
+
// Return a Promise that resolves when the request completes
|
|
25
26
|
return new Promise(async (resolve) => {
|
|
26
27
|
if (!page && !paginate && !search) {
|
|
28
|
+
// If no search parameters, make a regular GET request
|
|
27
29
|
await window.axios.get(url).then(response => {
|
|
28
|
-
resolve(response);
|
|
30
|
+
resolve(response); // Resolve the Promise with the response
|
|
29
31
|
});
|
|
30
32
|
} else {
|
|
33
|
+
// If search parameters exist, append them to the URL
|
|
31
34
|
await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
32
|
-
resolve(response);
|
|
35
|
+
resolve(response); // Resolve the Promise with the response
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
38
|
})
|
|
36
39
|
}
|
|
40
|
+
|
|
41
|
+
// Method to perform a POST request
|
|
37
42
|
async post(url) {
|
|
38
|
-
//
|
|
39
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
40
|
-
// const search = router.currentRoute.value.query.search
|
|
43
|
+
// Retrieve values from search parameters
|
|
41
44
|
const page = searchParams.get('page');
|
|
42
45
|
const paginate = searchParams.get('paginate');
|
|
43
46
|
const search = searchParams.get('search');
|
|
44
47
|
|
|
48
|
+
// Return a Promise that resolves when the request completes
|
|
45
49
|
return new Promise(async (resolve) => {
|
|
46
50
|
if (!page && !paginate && !search) {
|
|
51
|
+
// If no search parameters, make a regular POST request
|
|
47
52
|
await window.axios.post(url).then(response => {
|
|
48
|
-
resolve(response);
|
|
53
|
+
resolve(response); // Resolve the Promise with the response
|
|
49
54
|
});
|
|
50
55
|
} else {
|
|
56
|
+
// If search parameters exist, append them to the URL
|
|
51
57
|
await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
52
|
-
resolve(response);
|
|
58
|
+
resolve(response); // Resolve the Promise with the response
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Method to perform a PUT request
|
|
65
|
+
async put(url) {
|
|
66
|
+
// Retrieve values from search parameters
|
|
67
|
+
const page = searchParams.get('page');
|
|
68
|
+
const paginate = searchParams.get('paginate');
|
|
69
|
+
const search = searchParams.get('search');
|
|
70
|
+
|
|
71
|
+
// Return a Promise that resolves when the request completes
|
|
72
|
+
return new Promise(async (resolve) => {
|
|
73
|
+
if (!page && !paginate && !search) {
|
|
74
|
+
// If no search parameters, make a regular PUT request
|
|
75
|
+
await window.axios.put(url).then(response => {
|
|
76
|
+
resolve(response); // Resolve the Promise with the response
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
// If search parameters exist, append them to the URL
|
|
80
|
+
await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
81
|
+
resolve(response); // Resolve the Promise with the response
|
|
53
82
|
});
|
|
54
83
|
}
|
|
55
84
|
})
|
|
56
85
|
}
|
|
57
86
|
}
|
|
58
87
|
|
|
88
|
+
// Import the "datatable" class from the local file "./datatable"
|
|
89
|
+
|
|
59
90
|
export { datatable as default };
|
|
@@ -4,62 +4,93 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["datatable-axios"] = factory(global.axios));
|
|
5
5
|
})(this, (function (axios) { 'use strict';
|
|
6
6
|
|
|
7
|
+
// Import the axios library
|
|
8
|
+
|
|
9
|
+
// Make the axios library globally available on the window object
|
|
7
10
|
window.axios = axios;
|
|
8
11
|
|
|
9
|
-
//
|
|
10
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
11
|
-
|
|
12
|
-
// Get individual query parameter values
|
|
12
|
+
// Import the axios instance from the local file "./axios"
|
|
13
13
|
|
|
14
|
+
// Parse the search parameters from the URL
|
|
15
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
14
16
|
|
|
15
17
|
class datatable {
|
|
16
18
|
constructor() {
|
|
17
|
-
|
|
18
|
-
// this.paginate = router.currentRoute.value.query.paginate
|
|
19
|
-
// this.search = router.currentRoute.value.query.search
|
|
19
|
+
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
// Method to perform a GET request
|
|
21
23
|
async get(url) {
|
|
22
|
-
//
|
|
23
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
24
|
-
// const search = router.currentRoute.value.query.search
|
|
24
|
+
// Retrieve values from search parameters
|
|
25
25
|
const page = searchParams.get('page');
|
|
26
26
|
const paginate = searchParams.get('paginate');
|
|
27
27
|
const search = searchParams.get('search');
|
|
28
28
|
|
|
29
|
+
// Return a Promise that resolves when the request completes
|
|
29
30
|
return new Promise(async (resolve) => {
|
|
30
31
|
if (!page && !paginate && !search) {
|
|
32
|
+
// If no search parameters, make a regular GET request
|
|
31
33
|
await window.axios.get(url).then(response => {
|
|
32
|
-
resolve(response);
|
|
34
|
+
resolve(response); // Resolve the Promise with the response
|
|
33
35
|
});
|
|
34
36
|
} else {
|
|
37
|
+
// If search parameters exist, append them to the URL
|
|
35
38
|
await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
36
|
-
resolve(response);
|
|
39
|
+
resolve(response); // Resolve the Promise with the response
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
})
|
|
40
43
|
}
|
|
44
|
+
|
|
45
|
+
// Method to perform a POST request
|
|
41
46
|
async post(url) {
|
|
42
|
-
//
|
|
43
|
-
// const paginate = router.currentRoute.value.query.paginate
|
|
44
|
-
// const search = router.currentRoute.value.query.search
|
|
47
|
+
// Retrieve values from search parameters
|
|
45
48
|
const page = searchParams.get('page');
|
|
46
49
|
const paginate = searchParams.get('paginate');
|
|
47
50
|
const search = searchParams.get('search');
|
|
48
51
|
|
|
52
|
+
// Return a Promise that resolves when the request completes
|
|
49
53
|
return new Promise(async (resolve) => {
|
|
50
54
|
if (!page && !paginate && !search) {
|
|
55
|
+
// If no search parameters, make a regular POST request
|
|
51
56
|
await window.axios.post(url).then(response => {
|
|
52
|
-
resolve(response);
|
|
57
|
+
resolve(response); // Resolve the Promise with the response
|
|
53
58
|
});
|
|
54
59
|
} else {
|
|
60
|
+
// If search parameters exist, append them to the URL
|
|
55
61
|
await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
56
|
-
resolve(response);
|
|
62
|
+
resolve(response); // Resolve the Promise with the response
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Method to perform a PUT request
|
|
69
|
+
async put(url) {
|
|
70
|
+
// Retrieve values from search parameters
|
|
71
|
+
const page = searchParams.get('page');
|
|
72
|
+
const paginate = searchParams.get('paginate');
|
|
73
|
+
const search = searchParams.get('search');
|
|
74
|
+
|
|
75
|
+
// Return a Promise that resolves when the request completes
|
|
76
|
+
return new Promise(async (resolve) => {
|
|
77
|
+
if (!page && !paginate && !search) {
|
|
78
|
+
// If no search parameters, make a regular PUT request
|
|
79
|
+
await window.axios.put(url).then(response => {
|
|
80
|
+
resolve(response); // Resolve the Promise with the response
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
// If search parameters exist, append them to the URL
|
|
84
|
+
await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
85
|
+
resolve(response); // Resolve the Promise with the response
|
|
57
86
|
});
|
|
58
87
|
}
|
|
59
88
|
})
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
91
|
|
|
92
|
+
// Import the "datatable" class from the local file "./datatable"
|
|
93
|
+
|
|
63
94
|
return datatable;
|
|
64
95
|
|
|
65
96
|
}));
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "datatable-axios",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A powerful npm package for effortless datatable interactions with seamless Axios calls. Effortlessly integrate search, paginate, and pagination functionalities into your projects with ease.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/datatable-axios.cjs.js",
|
|
7
|
-
"unpkg": "dist/datatable-axios.umd.js",
|
|
8
|
-
"jsdelivr": "dist/simple-datatables.umd.js",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./dist/datatable-axios.esm.js",
|
|
12
|
-
"require": "./dist/datatable-axios.cjs.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "npm run build:rollup",
|
|
17
|
-
"build:vite": "vite build",
|
|
18
|
-
"build:rollup": "rollup -c"
|
|
19
|
-
},
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/mahmudunnabikajal/datatable-axios.git"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"datatable",
|
|
26
|
-
"axiosdatatable",
|
|
27
|
-
"datatableaxios",
|
|
28
|
-
"datatable-axios",
|
|
29
|
-
"DataTables",
|
|
30
|
-
"DataTable",
|
|
31
|
-
"table",
|
|
32
|
-
"grid",
|
|
33
|
-
"filter",
|
|
34
|
-
"sort",
|
|
35
|
-
"page",
|
|
36
|
-
"javascript-plugin",
|
|
37
|
-
"vite",
|
|
38
|
-
"npm",
|
|
39
|
-
"package"
|
|
40
|
-
],
|
|
41
|
-
"author": "Mahmudun Nabi Kajal",
|
|
42
|
-
"license": "
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/mahmudunnabikajal/datatable-axios/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"axios": "*"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"vite": "^4.4.9",
|
|
52
|
-
"@rollup/plugin-commonjs": "^25.0.4",
|
|
53
|
-
"@rollup/plugin-node-resolve": "^15.2.0",
|
|
54
|
-
"rollup": "^3.28.0"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"axios": "^1.4.0"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "datatable-axios",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "A powerful npm package for effortless datatable interactions with seamless Axios calls. Effortlessly integrate search, paginate, and pagination functionalities into your projects with ease.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/datatable-axios.cjs.js",
|
|
7
|
+
"unpkg": "dist/datatable-axios.umd.js",
|
|
8
|
+
"jsdelivr": "dist/simple-datatables.umd.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/datatable-axios.esm.js",
|
|
12
|
+
"require": "./dist/datatable-axios.cjs.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "npm run build:rollup",
|
|
17
|
+
"build:vite": "vite build",
|
|
18
|
+
"build:rollup": "rollup -c"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/mahmudunnabikajal/datatable-axios.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"datatable",
|
|
26
|
+
"axiosdatatable",
|
|
27
|
+
"datatableaxios",
|
|
28
|
+
"datatable-axios",
|
|
29
|
+
"DataTables",
|
|
30
|
+
"DataTable",
|
|
31
|
+
"table",
|
|
32
|
+
"grid",
|
|
33
|
+
"filter",
|
|
34
|
+
"sort",
|
|
35
|
+
"page",
|
|
36
|
+
"javascript-plugin",
|
|
37
|
+
"vite",
|
|
38
|
+
"npm",
|
|
39
|
+
"package"
|
|
40
|
+
],
|
|
41
|
+
"author": "Mahmudun Nabi Kajal",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/mahmudunnabikajal/datatable-axios/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://mahmudunnabikajal.github.io/datatable-axios/",
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"axios": "*"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"vite": "^4.4.9",
|
|
52
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
53
|
+
"@rollup/plugin-node-resolve": "^15.2.0",
|
|
54
|
+
"rollup": "^3.28.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"axios": "^1.4.0"
|
|
58
|
+
}
|
|
59
|
+
}
|