datatable-axios 0.0.10 → 1.1.0

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.
@@ -1,96 +1,84 @@
1
1
  'use strict';
2
2
 
3
- var axios = require('axios');
3
+ /**
4
+ * A datatable-axios class
5
+ * @class
6
+ */
7
+ class datatable {
8
+ constructor() {}
4
9
 
5
- // Import the axios library
6
-
7
- // Make the axios library globally available on the window object
8
- window.axios = axios;
10
+ /**
11
+ * Method to perform a GET request
12
+ * @param {string} url - The url of API endpoint
13
+ * @returns {Promise<object>} Server response from API endpoint
14
+ */
15
+ async get(url) {
16
+ // Parse the search parameters from the URL
17
+ let searchParams = new URLSearchParams(window.location.search);
9
18
 
10
- // Import the axios instance from the local file "./axios"
11
-
12
- class datatable {
13
- constructor() {
14
-
15
- }
16
-
17
- // Method to perform a GET request
18
- async get(url) {
19
- // Parse the search parameters from the URL
20
- let searchParams = new URLSearchParams(window.location.search);
21
-
22
- // Retrieve values from search parameters
23
- let page = searchParams.get('page');
24
- let paginate = searchParams.get('paginate');
25
- let search = searchParams.get('search');
26
-
27
- // Return a Promise that resolves when the request completes
28
- return new Promise(async (resolve) => {
29
- if (!page && !paginate && !search) {
30
- // If no search parameters, make a regular GET request
31
- await window.axios.get(url).then(response => {
32
- resolve(response); // Resolve the Promise with the response
33
- });
34
- } else {
35
- // If search parameters exist, append them to the URL
36
- await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
37
- resolve(response); // Resolve the Promise with the response
38
- });
39
- }
40
- })
41
- }
42
-
43
- // Method to perform a POST request
44
- async post(url) {
45
- // Parse the search parameters from the URL
46
- let searchParams = new URLSearchParams(window.location.search);
47
-
48
- // Retrieve values from search parameters
49
- let page = searchParams.get('page');
50
- let paginate = searchParams.get('paginate');
51
- let search = searchParams.get('search');
52
-
53
- // Return a Promise that resolves when the request completes
54
- return new Promise(async (resolve) => {
55
- if (!page && !paginate && !search) {
56
- // If no search parameters, make a regular POST request
57
- await window.axios.post(url).then(response => {
58
- resolve(response); // Resolve the Promise with the response
59
- });
60
- } else {
61
- // If search parameters exist, append them to the URL
62
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
63
- resolve(response); // Resolve the Promise with the response
64
- });
65
- }
66
- })
67
- }
68
-
69
- // Method to perform a PUT request
70
- async put(url) {
71
- // Parse the search parameters from the URL
72
- let searchParams = new URLSearchParams(window.location.search);
73
-
74
- // Retrieve values from search parameters
75
- let page = searchParams.get('page');
76
- let paginate = searchParams.get('paginate');
77
- let search = searchParams.get('search');
78
-
79
- // Return a Promise that resolves when the request completes
80
- return new Promise(async (resolve) => {
81
- if (!page && !paginate && !search) {
82
- // If no search parameters, make a regular PUT request
83
- await window.axios.put(url).then(response => {
84
- resolve(response); // Resolve the Promise with the response
85
- });
86
- } else {
87
- // If search parameters exist, append them to the URL
88
- await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
89
- resolve(response); // Resolve the Promise with the response
90
- });
91
- }
92
- })
93
- }
19
+ // Retrieve values from search parameters
20
+ let page = searchParams.get("page");
21
+ let paginate = searchParams.get("paginate");
22
+ let search = searchParams.get("search");
23
+
24
+ // If no search parameters, make a regular GET request
25
+ if (!page && !paginate && !search) {
26
+ return window.axios.get(url);
27
+ }
28
+
29
+ // If search parameters exist, append them to the URL
30
+ return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
31
+ }
32
+
33
+ /**
34
+ * Method to perform a POST request
35
+ *
36
+ * @async
37
+ * @param {string} url - The url of API endpoint
38
+ * @returns {Promise<object>} Server response from API endpoint
39
+ */
40
+ async post(url) {
41
+ // Parse the search parameters from the URL
42
+ let searchParams = new URLSearchParams(window.location.search);
43
+
44
+ // Retrieve values from search parameters
45
+ let page = searchParams.get("page");
46
+ let paginate = searchParams.get("paginate");
47
+ let search = searchParams.get("search");
48
+
49
+ // If no search parameters, make a regular POST request
50
+ if (!page && !paginate && !search) {
51
+ return window.axios.post(url);
52
+ }
53
+
54
+ // If search parameters exist, append them to the URL
55
+ return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
56
+ }
57
+
58
+ /**
59
+ * Method to perform a PUT request
60
+ *
61
+ * @async
62
+ * @param {string} url - The url of API endpoint
63
+ * @returns {Promise<object>} Server response from API endpoint
64
+ */
65
+ async put(url) {
66
+ // Parse the search parameters from the URL
67
+ let searchParams = new URLSearchParams(window.location.search);
68
+
69
+ // Retrieve values from search parameters
70
+ let page = searchParams.get("page");
71
+ let paginate = searchParams.get("paginate");
72
+ let search = searchParams.get("search");
73
+
74
+ // If no search parameters, make a regular PUT request
75
+ if (!page && !paginate && !search) {
76
+ return window.axios.put(url);
77
+ }
78
+
79
+ // If search parameters exist, append them to the URL
80
+ return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
81
+ }
94
82
  }
95
83
 
96
84
  // Import the "datatable" class from the local file "./datatable"
@@ -1,94 +1,82 @@
1
- import axios from 'axios';
1
+ /**
2
+ * A datatable-axios class
3
+ * @class
4
+ */
5
+ class datatable {
6
+ constructor() {}
2
7
 
3
- // Import the axios library
4
-
5
- // Make the axios library globally available on the window object
6
- window.axios = axios;
8
+ /**
9
+ * Method to perform a GET request
10
+ * @param {string} url - The url of API endpoint
11
+ * @returns {Promise<object>} Server response from API endpoint
12
+ */
13
+ async get(url) {
14
+ // Parse the search parameters from the URL
15
+ let searchParams = new URLSearchParams(window.location.search);
7
16
 
8
- // Import the axios instance from the local file "./axios"
9
-
10
- class datatable {
11
- constructor() {
12
-
13
- }
14
-
15
- // Method to perform a GET request
16
- async get(url) {
17
- // Parse the search parameters from the URL
18
- let searchParams = new URLSearchParams(window.location.search);
19
-
20
- // Retrieve values from search parameters
21
- let page = searchParams.get('page');
22
- let paginate = searchParams.get('paginate');
23
- let search = searchParams.get('search');
24
-
25
- // Return a Promise that resolves when the request completes
26
- return new Promise(async (resolve) => {
27
- if (!page && !paginate && !search) {
28
- // If no search parameters, make a regular GET request
29
- await window.axios.get(url).then(response => {
30
- resolve(response); // Resolve the Promise with the response
31
- });
32
- } else {
33
- // If search parameters exist, append them to the URL
34
- await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
35
- resolve(response); // Resolve the Promise with the response
36
- });
37
- }
38
- })
39
- }
40
-
41
- // Method to perform a POST request
42
- async post(url) {
43
- // Parse the search parameters from the URL
44
- let searchParams = new URLSearchParams(window.location.search);
45
-
46
- // Retrieve values from search parameters
47
- let page = searchParams.get('page');
48
- let paginate = searchParams.get('paginate');
49
- let search = searchParams.get('search');
50
-
51
- // Return a Promise that resolves when the request completes
52
- return new Promise(async (resolve) => {
53
- if (!page && !paginate && !search) {
54
- // If no search parameters, make a regular POST request
55
- await window.axios.post(url).then(response => {
56
- resolve(response); // Resolve the Promise with the response
57
- });
58
- } else {
59
- // If search parameters exist, append them to the URL
60
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
61
- resolve(response); // Resolve the Promise with the response
62
- });
63
- }
64
- })
65
- }
66
-
67
- // Method to perform a PUT request
68
- async put(url) {
69
- // Parse the search parameters from the URL
70
- let searchParams = new URLSearchParams(window.location.search);
71
-
72
- // Retrieve values from search parameters
73
- let page = searchParams.get('page');
74
- let paginate = searchParams.get('paginate');
75
- let search = searchParams.get('search');
76
-
77
- // Return a Promise that resolves when the request completes
78
- return new Promise(async (resolve) => {
79
- if (!page && !paginate && !search) {
80
- // If no search parameters, make a regular PUT request
81
- await window.axios.put(url).then(response => {
82
- resolve(response); // Resolve the Promise with the response
83
- });
84
- } else {
85
- // If search parameters exist, append them to the URL
86
- await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
87
- resolve(response); // Resolve the Promise with the response
88
- });
89
- }
90
- })
91
- }
17
+ // Retrieve values from search parameters
18
+ let page = searchParams.get("page");
19
+ let paginate = searchParams.get("paginate");
20
+ let search = searchParams.get("search");
21
+
22
+ // If no search parameters, make a regular GET request
23
+ if (!page && !paginate && !search) {
24
+ return window.axios.get(url);
25
+ }
26
+
27
+ // If search parameters exist, append them to the URL
28
+ return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
29
+ }
30
+
31
+ /**
32
+ * Method to perform a POST request
33
+ *
34
+ * @async
35
+ * @param {string} url - The url of API endpoint
36
+ * @returns {Promise<object>} Server response from API endpoint
37
+ */
38
+ async post(url) {
39
+ // Parse the search parameters from the URL
40
+ let searchParams = new URLSearchParams(window.location.search);
41
+
42
+ // Retrieve values from search parameters
43
+ let page = searchParams.get("page");
44
+ let paginate = searchParams.get("paginate");
45
+ let search = searchParams.get("search");
46
+
47
+ // If no search parameters, make a regular POST request
48
+ if (!page && !paginate && !search) {
49
+ return window.axios.post(url);
50
+ }
51
+
52
+ // If search parameters exist, append them to the URL
53
+ return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
54
+ }
55
+
56
+ /**
57
+ * Method to perform a PUT request
58
+ *
59
+ * @async
60
+ * @param {string} url - The url of API endpoint
61
+ * @returns {Promise<object>} Server response from API endpoint
62
+ */
63
+ async put(url) {
64
+ // Parse the search parameters from the URL
65
+ let searchParams = new URLSearchParams(window.location.search);
66
+
67
+ // Retrieve values from search parameters
68
+ let page = searchParams.get("page");
69
+ let paginate = searchParams.get("paginate");
70
+ let search = searchParams.get("search");
71
+
72
+ // If no search parameters, make a regular PUT request
73
+ if (!page && !paginate && !search) {
74
+ return window.axios.put(url);
75
+ }
76
+
77
+ // If search parameters exist, append them to the URL
78
+ return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
79
+ }
92
80
  }
93
81
 
94
82
  // Import the "datatable" class from the local file "./datatable"
@@ -1,102 +1,92 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('axios')) :
3
- typeof define === 'function' && define.amd ? define(['axios'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["datatable-axios"] = factory(global.axios));
5
- })(this, (function (axios) { 'use strict';
6
-
7
- // Import the axios library
8
-
9
- // Make the axios library globally available on the window object
10
- window.axios = axios;
11
-
12
- // Import the axios instance from the local file "./axios"
13
-
14
- class datatable {
15
- constructor() {
16
-
17
- }
18
-
19
- // Method to perform a GET request
20
- async get(url) {
21
- // Parse the search parameters from the URL
22
- let searchParams = new URLSearchParams(window.location.search);
23
-
24
- // Retrieve values from search parameters
25
- let page = searchParams.get('page');
26
- let paginate = searchParams.get('paginate');
27
- let search = searchParams.get('search');
28
-
29
- // Return a Promise that resolves when the request completes
30
- return new Promise(async (resolve) => {
31
- if (!page && !paginate && !search) {
32
- // If no search parameters, make a regular GET request
33
- await window.axios.get(url).then(response => {
34
- resolve(response); // Resolve the Promise with the response
35
- });
36
- } else {
37
- // If search parameters exist, append them to the URL
38
- await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
39
- resolve(response); // Resolve the Promise with the response
40
- });
41
- }
42
- })
43
- }
44
-
45
- // Method to perform a POST request
46
- async post(url) {
47
- // Parse the search parameters from the URL
48
- let searchParams = new URLSearchParams(window.location.search);
49
-
50
- // Retrieve values from search parameters
51
- let page = searchParams.get('page');
52
- let paginate = searchParams.get('paginate');
53
- let search = searchParams.get('search');
54
-
55
- // Return a Promise that resolves when the request completes
56
- return new Promise(async (resolve) => {
57
- if (!page && !paginate && !search) {
58
- // If no search parameters, make a regular POST request
59
- await window.axios.post(url).then(response => {
60
- resolve(response); // Resolve the Promise with the response
61
- });
62
- } else {
63
- // If search parameters exist, append them to the URL
64
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
65
- resolve(response); // Resolve the Promise with the response
66
- });
67
- }
68
- })
69
- }
70
-
71
- // Method to perform a PUT request
72
- async put(url) {
73
- // Parse the search parameters from the URL
74
- let searchParams = new URLSearchParams(window.location.search);
75
-
76
- // Retrieve values from search parameters
77
- let page = searchParams.get('page');
78
- let paginate = searchParams.get('paginate');
79
- let search = searchParams.get('search');
80
-
81
- // Return a Promise that resolves when the request completes
82
- return new Promise(async (resolve) => {
83
- if (!page && !paginate && !search) {
84
- // If no search parameters, make a regular PUT request
85
- await window.axios.put(url).then(response => {
86
- resolve(response); // Resolve the Promise with the response
87
- });
88
- } else {
89
- // If search parameters exist, append them to the URL
90
- await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
91
- resolve(response); // Resolve the Promise with the response
92
- });
93
- }
94
- })
95
- }
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["datatable-axios"] = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ /**
8
+ * A datatable-axios class
9
+ * @class
10
+ */
11
+ class datatable {
12
+ constructor() {}
13
+
14
+ /**
15
+ * Method to perform a GET request
16
+ * @param {string} url - The url of API endpoint
17
+ * @returns {Promise<object>} Server response from API endpoint
18
+ */
19
+ async get(url) {
20
+ // Parse the search parameters from the URL
21
+ let searchParams = new URLSearchParams(window.location.search);
22
+
23
+ // Retrieve values from search parameters
24
+ let page = searchParams.get("page");
25
+ let paginate = searchParams.get("paginate");
26
+ let search = searchParams.get("search");
27
+
28
+ // If no search parameters, make a regular GET request
29
+ if (!page && !paginate && !search) {
30
+ return window.axios.get(url);
31
+ }
32
+
33
+ // If search parameters exist, append them to the URL
34
+ return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
35
+ }
36
+
37
+ /**
38
+ * Method to perform a POST request
39
+ *
40
+ * @async
41
+ * @param {string} url - The url of API endpoint
42
+ * @returns {Promise<object>} Server response from API endpoint
43
+ */
44
+ async post(url) {
45
+ // Parse the search parameters from the URL
46
+ let searchParams = new URLSearchParams(window.location.search);
47
+
48
+ // Retrieve values from search parameters
49
+ let page = searchParams.get("page");
50
+ let paginate = searchParams.get("paginate");
51
+ let search = searchParams.get("search");
52
+
53
+ // If no search parameters, make a regular POST request
54
+ if (!page && !paginate && !search) {
55
+ return window.axios.post(url);
56
+ }
57
+
58
+ // If search parameters exist, append them to the URL
59
+ return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
60
+ }
61
+
62
+ /**
63
+ * Method to perform a PUT request
64
+ *
65
+ * @async
66
+ * @param {string} url - The url of API endpoint
67
+ * @returns {Promise<object>} Server response from API endpoint
68
+ */
69
+ async put(url) {
70
+ // Parse the search parameters from the URL
71
+ let searchParams = new URLSearchParams(window.location.search);
72
+
73
+ // Retrieve values from search parameters
74
+ let page = searchParams.get("page");
75
+ let paginate = searchParams.get("paginate");
76
+ let search = searchParams.get("search");
77
+
78
+ // If no search parameters, make a regular PUT request
79
+ if (!page && !paginate && !search) {
80
+ return window.axios.put(url);
81
+ }
82
+
83
+ // If search parameters exist, append them to the URL
84
+ return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
96
85
  }
86
+ }
97
87
 
98
- // Import the "datatable" class from the local file "./datatable"
88
+ // Import the "datatable" class from the local file "./datatable"
99
89
 
100
- return datatable;
90
+ return datatable;
101
91
 
102
92
  }));
@@ -0,0 +1,29 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import prettier from "eslint-plugin-prettier";
4
+ import prettierConfig from "eslint-config-prettier";
5
+
6
+ export default [
7
+ js.configs.recommended,
8
+ {
9
+ files: ["**/*.js"],
10
+ languageOptions: {
11
+ ecmaVersion: "latest",
12
+ sourceType: "module",
13
+ globals: {
14
+ ...globals.browser,
15
+ },
16
+ },
17
+ plugins: {
18
+ prettier,
19
+ },
20
+ rules: {
21
+ "prettier/prettier": "error",
22
+ "no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
23
+ },
24
+ },
25
+ prettierConfig,
26
+ {
27
+ ignores: ["node_modules/", "coverage/", "dist/"],
28
+ },
29
+ ];