2
redux-saga를 사용하고 API 호출을 수행하는 생성자 checkUsername
을 생성했습니다. 나는 const username
이 API의 응답과 같지만 undefined
을 얻었습니다. API res
전화 내 checkUsername
기능에 비록 Redux-saga가 API의 응답을 기다리지 않습니다.
function* checkUsername(action) {
try {
const username = yield call(Api.checkUsername, action.username);
yield put({type: actions.USERNAME_CHECK_SUCCEEDED, username});
} catch (e) {
yield put({type: actions.USERNAME_CHECK_FAILED, message: e.message});
}
}
은 동일
{"isExist": false}
입니다 :
checkUsername(username) {
fetch(url, {
'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
}).then(response => response.json())
.then(res => res)
.catch(error => console.error(error));
},
내 const username
이 {"isExist": false}
동일하지 않은 이유는 무엇입니까?
정말 고마워요! – rel1x
내 날을 저장했습니다! 감사.! –