datatable-axios 0.0.4 → 0.0.6

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