Skip to content

Commit 88c79df

Browse files
committed
ch09 lvl1 sec94, using-axios-with-function-components
1 parent 9fdc1a0 commit 88c79df

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crud-api/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ const App: React.FC = () => {
9191
timeout: 5000
9292
})
9393
.then(({ data }) => {
94-
setLoading(false)
9594
setPosts(data)
95+
setLoading(false)
9696
})
9797
.catch(ex => {
98-
setLoading(false)
9998
const { response: { status = 0 } = { status: 0 }, code = '' } = ex
10099
const error = axios.isCancel(ex)
101100
? 'request canceled'
@@ -105,6 +104,7 @@ const App: React.FC = () => {
105104
? 'resource not found'
106105
: 'unexpected error occured'
107106
setError(error)
107+
setLoading(false)
108108
})
109109
}
110110

0 commit comments

Comments
 (0)