Skip to content

Commit 0cf53c0

Browse files
authored
Merge pull request #4 from ninetynine/feature/remove-axios
Remove axios dependency
2 parents 8ee8a7e + 8ce0eaa commit 0cf53c0

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

dist/ajax-table.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ninetynine/react-table",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A package that provides a managed React table for both static and dynamic data",
55
"author": "Dexter Marks-Barber <[email protected]>",
66
"license": "LGPL-3.0-only",
@@ -47,7 +47,6 @@
4747
"react-dom": "^16.13.0"
4848
},
4949
"dependencies": {
50-
"axios": "^0.19.2",
5150
"classnames": "^2.2.6",
5251
"core-js": "3",
5352
"prop-types": "^15.7.2",

src/ajax-table.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
/* globals fetch */
12
import React from 'react'
23
import PropTypes from 'prop-types'
34
import { useSetState, useMount, useUpdateEffect } from 'react-use'
4-
import axios from 'axios'
55

66
import { NOOP } from './helpers'
77
import Table from './table'
88

99
const AjaxTable = ({ url, params, responseManipulator, onLoad, rows, loadingRow, emptyRow, ...rest }) => {
1010
const [state, setState] = useSetState({ loading: true, rows })
1111

12-
const get = async () => {
13-
const { data: response } = await axios.get(url, { params })
14-
const rows = responseManipulator(response)
15-
16-
setState({ loading: false, rows })
17-
onLoad(rows)
18-
}
12+
const get = () => (
13+
fetch(url, { credentials: 'include' })
14+
.then(response => response.json())
15+
.then(response => responseManipulator(response))
16+
.then(rows => {
17+
setState({ loading: false, rows })
18+
onLoad(rows)
19+
})
20+
)
1921

2022
// Get rows when mounted
2123
useMount(() => { get() })

yarn.lock

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -972,13 +972,6 @@ atob@^2.1.2:
972972
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
973973
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
974974

975-
axios@^0.19.2:
976-
version "0.19.2"
977-
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
978-
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
979-
dependencies:
980-
follow-redirects "1.5.10"
981-
982975
babel-helper-evaluate-path@^0.5.0:
983976
version "0.5.0"
984977
resolved "https://registry.yarnpkg.com/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.5.0.tgz#a62fa9c4e64ff7ea5cea9353174ef023a900a67c"
@@ -1494,13 +1487,6 @@ debug-log@^1.0.0:
14941487
resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f"
14951488
integrity sha1-IwdjLUwEOCuN+KMvcLiVBG1SdF8=
14961489

1497-
debug@=3.1.0:
1498-
version "3.1.0"
1499-
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
1500-
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
1501-
dependencies:
1502-
ms "2.0.0"
1503-
15041490
debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
15051491
version "2.6.9"
15061492
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -1995,13 +1981,6 @@ flatted@^2.0.0:
19951981
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
19961982
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
19971983

1998-
1999-
version "1.5.10"
2000-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
2001-
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
2002-
dependencies:
2003-
debug "=3.1.0"
2004-
20051984
for-in@^1.0.2:
20061985
version "1.0.2"
20071986
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"

0 commit comments

Comments
 (0)