Toggle navigation
Toggle navigation
This project
Loading...
Sign in
khusat
/
khusat-front
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이준호
2020-12-04 20:43:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
63a71dbbf6ef5e4385b838397172bf03b813a2d1
63a71dbb
1 parent
c32336d3
[REFACTOR] redux-thunk 미들웨어 추가로 리팩토링 + api 모듈화 작업
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
0 deletions
src/api/getQuestion.js
src/api/getResult.js
src/store/action/result.js
src/store/action/survey.js
src/api/getQuestion.js
0 → 100644
View file @
63a71db
import
axios
from
'axios'
;
const
getQuestion
=
async
()
=>
{
const
res
=
axios
.
get
(
"getquestions"
);
return
res
;
}
export
default
getQuestion
;
\ No newline at end of file
src/api/getResult.js
0 → 100644
View file @
63a71db
import
axios
from
'axios'
;
const
getResult
=
async
(
answer
)
=>
{
const
res
=
await
axios
.
post
(
"submit"
,
answer
);
return
res
;
}
export
default
getResult
;
\ No newline at end of file
src/store/action/result.js
View file @
63a71db
import
getResultApi
from
'../../api/getResult'
;
// action
const
GET_RESULT
=
'GET_RESULT'
;
const
GET_RESULT_SUCCESS
=
'GET_RESULT_SUCCESS'
;
...
...
@@ -14,6 +16,18 @@ const initialState = {
error
:
null
}
export
function
getResultThunk
(
answer
){
return
async
(
dispatch
)
=>
{
dispatch
(
getResult
());
try
{
const
{
data
}
=
await
getResultApi
(
answer
);
dispatch
(
getResultSuccess
(
data
));
}
catch
(
err
){
dispatch
(
getResultError
());
}
}
}
function
result
(
state
=
initialState
,
action
...
...
src/store/action/survey.js
View file @
63a71db
import
getQuestionApi
from
'../../api/getQuestion'
;
// action
const
GET_SURVEY
=
'GET_SURVEY'
;
const
GET_SURVEY_SUCCESS
=
'GET_SURVEY_SUCCESS'
;
...
...
@@ -14,6 +16,18 @@ const initialState = {
error
:
null
}
export
function
getQuestionThunk
(){
return
async
(
dispatch
)
=>
{
dispatch
(
getSurvey
());
try
{
const
{
data
}
=
await
getQuestionApi
();
dispatch
(
getSurveySuccess
(
data
));
}
catch
(
err
){
dispatch
(
getSurveyError
());
}
}
}
function
survey
(
state
=
initialState
,
action
...
...
Please
register
or
login
to post a comment