datatable-axios 0.0.4 → 0.0.5

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.
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+
5
+ window.axios = axios;
6
+
7
+ // Create a URLSearchParams object to parse the query string
8
+ const searchParams = new URLSearchParams(window.location.search);
9
+
10
+ // Get individual query parameter values
11
+
12
+
13
+ class datatable {
14
+ constructor() {
15
+ // this.page = router.currentRoute.value.query.page
16
+ // this.paginate = router.currentRoute.value.query.paginate
17
+ // this.search = router.currentRoute.value.query.search
18
+ }
19
+ async get(url) {
20
+ // const page = router.currentRoute.value.query.page
21
+ // const paginate = router.currentRoute.value.query.paginate
22
+ // const search = router.currentRoute.value.query.search
23
+ const page = searchParams.get('page');
24
+ const paginate = searchParams.get('paginate');
25
+ const search = searchParams.get('search');
26
+
27
+ return new Promise(async (resolve) => {
28
+ if (!page && !paginate && !search) {
29
+ await window.axios.get(url).then(response => {
30
+ resolve(response);
31
+ });
32
+ } else {
33
+ await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
34
+ resolve(response);
35
+ });
36
+ }
37
+ })
38
+ }
39
+ async post(url) {
40
+ // const page = router.currentRoute.value.query.page
41
+ // const paginate = router.currentRoute.value.query.paginate
42
+ // const search = router.currentRoute.value.query.search
43
+ const page = searchParams.get('page');
44
+ const paginate = searchParams.get('paginate');
45
+ const search = searchParams.get('search');
46
+
47
+ return new Promise(async (resolve) => {
48
+ if (!page && !paginate && !search) {
49
+ await window.axios.post(url).then(response => {
50
+ resolve(response);
51
+ });
52
+ } else {
53
+ await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
54
+ resolve(response);
55
+ });
56
+ }
57
+ })
58
+ }
59
+ }
60
+
61
+ module.exports = datatable;
@@ -0,0 +1,59 @@
1
+ import axios from 'axios';
2
+
3
+ window.axios = axios;
4
+
5
+ // Create a URLSearchParams object to parse the query string
6
+ const searchParams = new URLSearchParams(window.location.search);
7
+
8
+ // Get individual query parameter values
9
+
10
+
11
+ class datatable {
12
+ constructor() {
13
+ // this.page = router.currentRoute.value.query.page
14
+ // this.paginate = router.currentRoute.value.query.paginate
15
+ // this.search = router.currentRoute.value.query.search
16
+ }
17
+ async get(url) {
18
+ // const page = router.currentRoute.value.query.page
19
+ // const paginate = router.currentRoute.value.query.paginate
20
+ // const search = router.currentRoute.value.query.search
21
+ const page = searchParams.get('page');
22
+ const paginate = searchParams.get('paginate');
23
+ const search = searchParams.get('search');
24
+
25
+ return new Promise(async (resolve) => {
26
+ if (!page && !paginate && !search) {
27
+ await window.axios.get(url).then(response => {
28
+ resolve(response);
29
+ });
30
+ } else {
31
+ await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
32
+ resolve(response);
33
+ });
34
+ }
35
+ })
36
+ }
37
+ async post(url) {
38
+ // const page = router.currentRoute.value.query.page
39
+ // const paginate = router.currentRoute.value.query.paginate
40
+ // const search = router.currentRoute.value.query.search
41
+ const page = searchParams.get('page');
42
+ const paginate = searchParams.get('paginate');
43
+ const search = searchParams.get('search');
44
+
45
+ return new Promise(async (resolve) => {
46
+ if (!page && !paginate && !search) {
47
+ await window.axios.post(url).then(response => {
48
+ resolve(response);
49
+ });
50
+ } else {
51
+ await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
52
+ resolve(response);
53
+ });
54
+ }
55
+ })
56
+ }
57
+ }
58
+
59
+ export { datatable as default };