datatable-axios 0.0.9 → 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,90 +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
- // Parse the search parameters from the URL
13
- const searchParams = new URLSearchParams(window.location.search);
14
-
15
- class datatable {
16
- constructor() {
17
-
18
- }
19
-
20
- // Method to perform a GET request
21
- async get(url) {
22
- // Retrieve values from search parameters
23
- const page = searchParams.get('page');
24
- const paginate = searchParams.get('paginate');
25
- const 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
- // Retrieve values from search parameters
46
- const page = searchParams.get('page');
47
- const paginate = searchParams.get('paginate');
48
- const search = searchParams.get('search');
49
-
50
- // Return a Promise that resolves when the request completes
51
- return new Promise(async (resolve) => {
52
- if (!page && !paginate && !search) {
53
- // If no search parameters, make a regular POST request
54
- await window.axios.post(url).then(response => {
55
- resolve(response); // Resolve the Promise with the response
56
- });
57
- } else {
58
- // If search parameters exist, append them to the URL
59
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(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
84
- });
85
- }
86
- })
87
- }
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
+ }
88
82
  }
89
83
 
90
84
  // Import the "datatable" class from the local file "./datatable"
@@ -1,88 +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
- // Parse the search parameters from the URL
11
- const searchParams = new URLSearchParams(window.location.search);
12
-
13
- class datatable {
14
- constructor() {
15
-
16
- }
17
-
18
- // Method to perform a GET request
19
- async get(url) {
20
- // Retrieve values from search parameters
21
- const page = searchParams.get('page');
22
- const paginate = searchParams.get('paginate');
23
- const 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
- // Retrieve values from search parameters
44
- const page = searchParams.get('page');
45
- const paginate = searchParams.get('paginate');
46
- const search = searchParams.get('search');
47
-
48
- // Return a Promise that resolves when the request completes
49
- return new Promise(async (resolve) => {
50
- if (!page && !paginate && !search) {
51
- // If no search parameters, make a regular POST request
52
- await window.axios.post(url).then(response => {
53
- resolve(response); // Resolve the Promise with the response
54
- });
55
- } else {
56
- // If search parameters exist, append them to the URL
57
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(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
82
- });
83
- }
84
- })
85
- }
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
+ }
86
80
  }
87
81
 
88
82
  // Import the "datatable" class from the local file "./datatable"
@@ -1,96 +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
- // Parse the search parameters from the URL
15
- const searchParams = new URLSearchParams(window.location.search);
16
-
17
- class datatable {
18
- constructor() {
19
-
20
- }
21
-
22
- // Method to perform a GET request
23
- async get(url) {
24
- // Retrieve values from search parameters
25
- const page = searchParams.get('page');
26
- const paginate = searchParams.get('paginate');
27
- const 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
- // Retrieve values from search parameters
48
- const page = searchParams.get('page');
49
- const paginate = searchParams.get('paginate');
50
- const search = searchParams.get('search');
51
-
52
- // Return a Promise that resolves when the request completes
53
- return new Promise(async (resolve) => {
54
- if (!page && !paginate && !search) {
55
- // If no search parameters, make a regular POST request
56
- await window.axios.post(url).then(response => {
57
- resolve(response); // Resolve the Promise with the response
58
- });
59
- } else {
60
- // If search parameters exist, append them to the URL
61
- await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(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
86
- });
87
- }
88
- })
89
- }
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}`);
90
85
  }
86
+ }
91
87
 
92
- // Import the "datatable" class from the local file "./datatable"
88
+ // Import the "datatable" class from the local file "./datatable"
93
89
 
94
- return datatable;
90
+ return datatable;
95
91
 
96
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
+ ];