datatable-axios 0.0.9 → 0.0.10
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/Readme.md +5 -5
- package/dist/datatable-axios.cjs.js +18 -12
- package/dist/datatable-axios.esm.js +18 -12
- package/dist/datatable-axios.js +29 -17
- package/dist/datatable-axios.umd.cjs +1 -1
- package/dist/datatable-axios.umd.js +18 -12
- package/package.json +5 -5
package/Readme.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/datatable-axios)
|
|
4
4
|
[](https://www.npmjs.com/package/datatable-axios)
|
|
5
5
|
[](#license)
|
|
6
|
-
|
|
6
|
+
[](https://mahmudunnabikajal.github.io/datatable-axios/ "Go to project documentation")
|
|
7
7
|
|
|
8
8
|
|
|
9
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.
|
|
@@ -13,18 +13,18 @@ Datatable Axios is a simple and convenient npm package that helps you make GET,
|
|
|
13
13
|
You can install Datatable Axios using npm:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install datatable-axios
|
|
16
|
+
npm install -g datatable-axios
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
# Why Datatable Axios?
|
|
20
20
|
Simplify your `HTTP calls without repetition`. Say goodbye to repeating steps for every datatable request!
|
|
21
21
|
|
|
22
|
-
- **`Cons:`** Without using the library, you can achieve the same functionality in Axios which
|
|
22
|
+
- **`Cons:`** Without using the library, you can achieve the same functionality in Axios which ***isn't readable & reusable***.
|
|
23
23
|
```js
|
|
24
24
|
const response = await axios.get('http://example.com/api/v1/products?page=2&paginate=25&search=we');
|
|
25
25
|
console.log(response.data);
|
|
26
26
|
```
|
|
27
|
-
- **`Pros:`** After using this library, you can achieve the same functionality of Axios in a
|
|
27
|
+
- **`Pros:`** After using this library, you can achieve the same functionality of Axios in a ***readable & reusable way***
|
|
28
28
|
```js
|
|
29
29
|
const response = await datatable.get('products');
|
|
30
30
|
console.log(response.data);
|
|
@@ -132,6 +132,6 @@ Released under [MIT License](LICENSE) by [@mahmudunnabikajal](https://github.com
|
|
|
132
132
|
|
|
133
133
|
# Author
|
|
134
134
|
Mahmudun Nabi Kajal<br />
|
|
135
|
-
Contact: [Linkedin](https://www.linkedin.com/in/mahmudun-nabi-kajal/), [GitHub](https://github.com/mahmudunnabikajal), [Gmail](mailto:mahmudunnabikajal)
|
|
135
|
+
Contact: [Linkedin](https://www.linkedin.com/in/mahmudun-nabi-kajal/), [GitHub](https://github.com/mahmudunnabikajal), [Gmail](mailto:mahmudunnabikajal), [Website](http://mahmudunnabikajal.com/)
|
|
136
136
|
|
|
137
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.
|
|
@@ -9,9 +9,6 @@ window.axios = axios;
|
|
|
9
9
|
|
|
10
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);
|
|
14
|
-
|
|
15
12
|
class datatable {
|
|
16
13
|
constructor() {
|
|
17
14
|
|
|
@@ -19,10 +16,13 @@ class datatable {
|
|
|
19
16
|
|
|
20
17
|
// Method to perform a GET request
|
|
21
18
|
async get(url) {
|
|
19
|
+
// Parse the search parameters from the URL
|
|
20
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
21
|
+
|
|
22
22
|
// Retrieve values from search parameters
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
let page = searchParams.get('page');
|
|
24
|
+
let paginate = searchParams.get('paginate');
|
|
25
|
+
let search = searchParams.get('search');
|
|
26
26
|
|
|
27
27
|
// Return a Promise that resolves when the request completes
|
|
28
28
|
return new Promise(async (resolve) => {
|
|
@@ -42,10 +42,13 @@ class datatable {
|
|
|
42
42
|
|
|
43
43
|
// Method to perform a POST request
|
|
44
44
|
async post(url) {
|
|
45
|
+
// Parse the search parameters from the URL
|
|
46
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
47
|
+
|
|
45
48
|
// Retrieve values from search parameters
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
let page = searchParams.get('page');
|
|
50
|
+
let paginate = searchParams.get('paginate');
|
|
51
|
+
let search = searchParams.get('search');
|
|
49
52
|
|
|
50
53
|
// Return a Promise that resolves when the request completes
|
|
51
54
|
return new Promise(async (resolve) => {
|
|
@@ -65,10 +68,13 @@ class datatable {
|
|
|
65
68
|
|
|
66
69
|
// Method to perform a PUT request
|
|
67
70
|
async put(url) {
|
|
71
|
+
// Parse the search parameters from the URL
|
|
72
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
73
|
+
|
|
68
74
|
// Retrieve values from search parameters
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
let page = searchParams.get('page');
|
|
76
|
+
let paginate = searchParams.get('paginate');
|
|
77
|
+
let search = searchParams.get('search');
|
|
72
78
|
|
|
73
79
|
// Return a Promise that resolves when the request completes
|
|
74
80
|
return new Promise(async (resolve) => {
|
|
@@ -7,9 +7,6 @@ window.axios = axios;
|
|
|
7
7
|
|
|
8
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);
|
|
12
|
-
|
|
13
10
|
class datatable {
|
|
14
11
|
constructor() {
|
|
15
12
|
|
|
@@ -17,10 +14,13 @@ class datatable {
|
|
|
17
14
|
|
|
18
15
|
// Method to perform a GET request
|
|
19
16
|
async get(url) {
|
|
17
|
+
// Parse the search parameters from the URL
|
|
18
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
19
|
+
|
|
20
20
|
// Retrieve values from search parameters
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
let page = searchParams.get('page');
|
|
22
|
+
let paginate = searchParams.get('paginate');
|
|
23
|
+
let search = searchParams.get('search');
|
|
24
24
|
|
|
25
25
|
// Return a Promise that resolves when the request completes
|
|
26
26
|
return new Promise(async (resolve) => {
|
|
@@ -40,10 +40,13 @@ class datatable {
|
|
|
40
40
|
|
|
41
41
|
// Method to perform a POST request
|
|
42
42
|
async post(url) {
|
|
43
|
+
// Parse the search parameters from the URL
|
|
44
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
45
|
+
|
|
43
46
|
// Retrieve values from search parameters
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
let page = searchParams.get('page');
|
|
48
|
+
let paginate = searchParams.get('paginate');
|
|
49
|
+
let search = searchParams.get('search');
|
|
47
50
|
|
|
48
51
|
// Return a Promise that resolves when the request completes
|
|
49
52
|
return new Promise(async (resolve) => {
|
|
@@ -63,10 +66,13 @@ class datatable {
|
|
|
63
66
|
|
|
64
67
|
// Method to perform a PUT request
|
|
65
68
|
async put(url) {
|
|
69
|
+
// Parse the search parameters from the URL
|
|
70
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
71
|
+
|
|
66
72
|
// Retrieve values from search parameters
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
let page = searchParams.get('page');
|
|
74
|
+
let paginate = searchParams.get('paginate');
|
|
75
|
+
let search = searchParams.get('search');
|
|
70
76
|
|
|
71
77
|
// Return a Promise that resolves when the request completes
|
|
72
78
|
return new Promise(async (resolve) => {
|
package/dist/datatable-axios.js
CHANGED
|
@@ -1,30 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
window.axios =
|
|
3
|
-
|
|
4
|
-
class r {
|
|
1
|
+
import r from "axios";
|
|
2
|
+
window.axios = r;
|
|
3
|
+
class g {
|
|
5
4
|
constructor() {
|
|
6
5
|
}
|
|
6
|
+
// Method to perform a GET request
|
|
7
7
|
async get(t) {
|
|
8
|
-
|
|
9
|
-
return new Promise(async (
|
|
10
|
-
!s && !n && !
|
|
11
|
-
|
|
12
|
-
}) : await window.axios.get(`${t}?page=${s}&paginate=${n}&search=${
|
|
13
|
-
|
|
8
|
+
let a = new URLSearchParams(window.location.search), s = a.get("page"), n = a.get("paginate"), i = a.get("search");
|
|
9
|
+
return new Promise(async (o) => {
|
|
10
|
+
!s && !n && !i ? await window.axios.get(t).then((e) => {
|
|
11
|
+
o(e);
|
|
12
|
+
}) : await window.axios.get(`${t}?page=${s}&paginate=${n}&search=${i}`).then((e) => {
|
|
13
|
+
o(e);
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
// Method to perform a POST request
|
|
17
18
|
async post(t) {
|
|
18
|
-
|
|
19
|
-
return new Promise(async (
|
|
20
|
-
!s && !n && !
|
|
21
|
-
|
|
22
|
-
}) : await window.axios.post(`${t}?page=${s}&paginate=${n}&search=${
|
|
23
|
-
|
|
19
|
+
let a = new URLSearchParams(window.location.search), s = a.get("page"), n = a.get("paginate"), i = a.get("search");
|
|
20
|
+
return new Promise(async (o) => {
|
|
21
|
+
!s && !n && !i ? await window.axios.post(t).then((e) => {
|
|
22
|
+
o(e);
|
|
23
|
+
}) : await window.axios.post(`${t}?page=${s}&paginate=${n}&search=${i}`).then((e) => {
|
|
24
|
+
o(e);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Method to perform a PUT request
|
|
29
|
+
async put(t) {
|
|
30
|
+
let a = new URLSearchParams(window.location.search), s = a.get("page"), n = a.get("paginate"), i = a.get("search");
|
|
31
|
+
return new Promise(async (o) => {
|
|
32
|
+
!s && !n && !i ? await window.axios.put(t).then((e) => {
|
|
33
|
+
o(e);
|
|
34
|
+
}) : await window.axios.put(`${t}?page=${s}&paginate=${n}&search=${i}`).then((e) => {
|
|
35
|
+
o(e);
|
|
24
36
|
});
|
|
25
37
|
});
|
|
26
38
|
}
|
|
27
39
|
}
|
|
28
40
|
export {
|
|
29
|
-
|
|
41
|
+
g as default
|
|
30
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("axios")):typeof define=="function"&&define.amd?define(["axios"],c):(r=typeof globalThis<"u"?globalThis:r||self,r["datatable-axios"]=c(r.axios))})(this,function(r){"use strict";window.axios=r;class c{constructor(){}async get(t){let e=new URLSearchParams(window.location.search),i=e.get("page"),n=e.get("paginate"),s=e.get("search");return new Promise(async o=>{!i&&!n&&!s?await window.axios.get(t).then(a=>{o(a)}):await window.axios.get(`${t}?page=${i}&paginate=${n}&search=${s}`).then(a=>{o(a)})})}async post(t){let e=new URLSearchParams(window.location.search),i=e.get("page"),n=e.get("paginate"),s=e.get("search");return new Promise(async o=>{!i&&!n&&!s?await window.axios.post(t).then(a=>{o(a)}):await window.axios.post(`${t}?page=${i}&paginate=${n}&search=${s}`).then(a=>{o(a)})})}async put(t){let e=new URLSearchParams(window.location.search),i=e.get("page"),n=e.get("paginate"),s=e.get("search");return new Promise(async o=>{!i&&!n&&!s?await window.axios.put(t).then(a=>{o(a)}):await window.axios.put(`${t}?page=${i}&paginate=${n}&search=${s}`).then(a=>{o(a)})})}}return c});
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
|
|
12
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);
|
|
16
|
-
|
|
17
14
|
class datatable {
|
|
18
15
|
constructor() {
|
|
19
16
|
|
|
@@ -21,10 +18,13 @@
|
|
|
21
18
|
|
|
22
19
|
// Method to perform a GET request
|
|
23
20
|
async get(url) {
|
|
21
|
+
// Parse the search parameters from the URL
|
|
22
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
23
|
+
|
|
24
24
|
// Retrieve values from search parameters
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
let page = searchParams.get('page');
|
|
26
|
+
let paginate = searchParams.get('paginate');
|
|
27
|
+
let search = searchParams.get('search');
|
|
28
28
|
|
|
29
29
|
// Return a Promise that resolves when the request completes
|
|
30
30
|
return new Promise(async (resolve) => {
|
|
@@ -44,10 +44,13 @@
|
|
|
44
44
|
|
|
45
45
|
// Method to perform a POST request
|
|
46
46
|
async post(url) {
|
|
47
|
+
// Parse the search parameters from the URL
|
|
48
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
49
|
+
|
|
47
50
|
// Retrieve values from search parameters
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
let page = searchParams.get('page');
|
|
52
|
+
let paginate = searchParams.get('paginate');
|
|
53
|
+
let search = searchParams.get('search');
|
|
51
54
|
|
|
52
55
|
// Return a Promise that resolves when the request completes
|
|
53
56
|
return new Promise(async (resolve) => {
|
|
@@ -67,10 +70,13 @@
|
|
|
67
70
|
|
|
68
71
|
// Method to perform a PUT request
|
|
69
72
|
async put(url) {
|
|
73
|
+
// Parse the search parameters from the URL
|
|
74
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
75
|
+
|
|
70
76
|
// Retrieve values from search parameters
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
let page = searchParams.get('page');
|
|
78
|
+
let paginate = searchParams.get('paginate');
|
|
79
|
+
let search = searchParams.get('search');
|
|
74
80
|
|
|
75
81
|
// Return a Promise that resolves when the request completes
|
|
76
82
|
return new Promise(async (resolve) => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datatable-axios",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"main": "dist/datatable-axios.cjs.js",
|
|
7
7
|
"unpkg": "dist/datatable-axios.umd.js",
|
|
8
|
-
"jsdelivr": "dist/
|
|
8
|
+
"jsdelivr": "dist/datatable-axios.umd.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": "./dist/datatable-axios.esm.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"datatable",
|
|
26
|
-
"axiosdatatable",
|
|
27
26
|
"datatableaxios",
|
|
28
27
|
"datatable-axios",
|
|
28
|
+
"axiosdatatable",
|
|
29
29
|
"DataTables",
|
|
30
30
|
"DataTable",
|
|
31
31
|
"table",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"npm",
|
|
39
39
|
"package"
|
|
40
40
|
],
|
|
41
|
-
"author": "Mahmudun Nabi Kajal",
|
|
41
|
+
"author": "Mahmudun Nabi Kajal <mahmudunnabikajal@gmail.com (https://mahmudunnabikajal.com/)",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"bugs": {
|
|
44
44
|
"url": "https://github.com/mahmudunnabikajal/datatable-axios/issues"
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"axios": "^1.4.0"
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|