-
카테고리
-
세부 분야
풀스택
-
해결 여부
해결됨
안녕하세요 리덕스 툴킷 관련질문입니다.
22.02.23 11:01 작성 조회수 83
0
안녕하세요. 리덕스 툴킷을 활용하려고 공부를 막 시작했습니다.
cra템플릿을 인스톨해서 보고있는데 비동기요청하는 부분이 조금 헷갈려 질문드립니다.
// typically used to make async requests.
export const incrementAsync = createAsyncThunk(
'counter/fetchCount',
async (amount) => {
const response = await fetchCount(amount);
// The value we return becomes the `fulfilled` action payload
return response.data;
}
);
위 함수를 extraReducers 내에서
extraReducers: (builder) => {
builder
.addCase(incrementAsync.pending, (state) => {
state.status = 'loading';
})
.addCase(incrementAsync.fulfilled, (state, action) => {
state.status = 'idle';
state.value += action.payload;
});
},
대기, 성공, 실패를 addCase해줘야한다 로 이해는 했는데요
그 다움 궁금한점은 api요청이 한가지 가 아닐텐데 많은 api요청들을 어떻게 추가해야하나요?
답변을 작성해보세요.
답변 1