Skip to content

Commit 6c8d64e

Browse files
committed
API call using proxy
1 parent f856db2 commit 6c8d64e

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/lazyload-app/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@types/node": "^16.7.13",
1111
"@types/react": "^17.0.20",
1212
"@types/react-dom": "^17.0.9",
13+
"axios": "^0.25.0",
1314
"react": "^17.0.2",
1415
"react-dom": "^17.0.2",
1516
"react-scripts": "5.0.0",
@@ -39,5 +40,6 @@
3940
"last 1 firefox version",
4041
"last 1 safari version"
4142
]
42-
}
43+
},
44+
"proxy": "http://localhost:8000/"
4345
}

packages/lazyload-app/src/App.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { lazy, Suspense } from 'react'
1+
import axios from 'axios'
2+
import { lazy, Suspense, useEffect } from 'react'
23
import Comp1 from './components/Comp1'
34
import Comp2 from './components/Comp2'
45

@@ -9,6 +10,13 @@ const Comp1Lazy = lazy(() => import(`${n1}`))
910
const Comp2Lazy = lazy(() => import(n2 + ''))
1011

1112
function App() {
13+
useEffect(() => {
14+
axios.post('/v1/users/login', {
15+
username: 'username',
16+
password: 'password',
17+
})
18+
}, [])
19+
1220
return (
1321
<div className="App">
1422
<Suspense fallback="loading ...">

packages/lazyload-app/yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,13 @@ axe-core@^4.3.5:
23732373
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.3.5.tgz#78d6911ba317a8262bfee292aeafcc1e04b49cc5"
23742374
integrity sha512-WKTW1+xAzhMS5dJsxWkliixlO/PqC4VhmO9T4juNYcaTg9jzWiJsou6m5pxWYGfigWbwzJWeFY6z47a+4neRXA==
23752375

2376+
axios@^0.25.0:
2377+
version "0.25.0"
2378+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a"
2379+
integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==
2380+
dependencies:
2381+
follow-redirects "^1.14.7"
2382+
23762383
axobject-query@^2.2.0:
23772384
version "2.2.0"
23782385
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
@@ -4145,7 +4152,7 @@ flatted@^3.1.0:
41454152
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2"
41464153
integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==
41474154

4148-
follow-redirects@^1.0.0:
4155+
follow-redirects@^1.0.0, follow-redirects@^1.14.7:
41494156
version "1.14.7"
41504157
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
41514158
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==

0 commit comments

Comments
 (0)