datatable-axios 0.0.1

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 ADDED
@@ -0,0 +1 @@
1
+ # Datatable Axios
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import datatable from './src/datatable'
2
+ export default datatable
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "datatable-axios",
3
+ "version": "0.0.1",
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
+ "main": "index.js",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mahmudunnabikajal/datatable-axios.git"
10
+ },
11
+ "keywords": [
12
+ "datatable",
13
+ "datatable-axios",
14
+ "DataTables",
15
+ "DataTable",
16
+ "table",
17
+ "grid",
18
+ "filter",
19
+ "sort",
20
+ "page",
21
+ "javascript-plugin",
22
+ "vite",
23
+ "npm",
24
+ "package"
25
+ ],
26
+ "author": "Mahmudun Nabi Kajal",
27
+ "license": "ISC",
28
+ "bugs": {
29
+ "url": "https://github.com/mahmudunnabikajal/datatable-axios/issues"
30
+ },
31
+ "homepage": "https://github.com/mahmudunnabikajal/datatable-axios#readme",
32
+ "devDependencies": {
33
+ "vite": "^4.4.9"
34
+ }
35
+ }
@@ -0,0 +1,55 @@
1
+ // Create a URLSearchParams object to parse the query string
2
+ const searchParams = new URLSearchParams(window.location.search)
3
+
4
+ // Get individual query parameter values
5
+
6
+
7
+ class datatable {
8
+ constructor() {
9
+ // this.page = router.currentRoute.value.query.page
10
+ // this.paginate = router.currentRoute.value.query.paginate
11
+ // this.search = router.currentRoute.value.query.search
12
+ }
13
+ async get(url) {
14
+ // const page = router.currentRoute.value.query.page
15
+ // const paginate = router.currentRoute.value.query.paginate
16
+ // const search = router.currentRoute.value.query.search
17
+ const page = searchParams.get('page')
18
+ const paginate = searchParams.get('paginate')
19
+ const search = searchParams.get('search')
20
+
21
+ return new Promise(async (resolve) => {
22
+ if (!page && !paginate && !search) {
23
+ await window.axios.get(url).then(response => {
24
+ resolve(response)
25
+ })
26
+ } else {
27
+ await window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
28
+ resolve(response)
29
+ })
30
+ }
31
+ })
32
+ }
33
+ async post(url) {
34
+ // const page = router.currentRoute.value.query.page
35
+ // const paginate = router.currentRoute.value.query.paginate
36
+ // const search = router.currentRoute.value.query.search
37
+ const page = searchParams.get('page')
38
+ const paginate = searchParams.get('paginate')
39
+ const search = searchParams.get('search')
40
+
41
+ return new Promise(async (resolve) => {
42
+ if (!page && !paginate && !search) {
43
+ await window.axios.post(url).then(response => {
44
+ resolve(response)
45
+ })
46
+ } else {
47
+ await window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
48
+ resolve(response)
49
+ })
50
+ }
51
+ })
52
+ }
53
+ }
54
+ const datatableAxios = new datatable()
55
+ export default datatableAxios
package/vite.config.js ADDED
@@ -0,0 +1,8 @@
1
+ export default {
2
+ build: {
3
+ lib: {
4
+ entry: './index.js',
5
+ name: 'datatable-axios'
6
+ }
7
+ }
8
+ }