当我的动作创建者触发mi saga时,我会出错
"Error: call: argument [object Object] is not a function
at check (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:126468:13)
at getFnCallDesc (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127645:22)
at call (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127658:25)
at loginRequestSaga$ (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:128869:38)
at tryCatch (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21519:19)
at Generator.invoke [as _invoke] (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21694:24)
at Generator.prototype.(anonymous function) [as next] (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21562:23)
at next (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127025:29)
at proc (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127000:5)
at runForkEffect (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127241:21)"
我正在运行本机0.57和最新版本的redux saga
这是我的传奇
import { put, call, select } from 'redux-saga/effects';
import { userServices } from '../../services';
import { userActions } from '../actions';
import { userConstants } from '../../constants/user.constants';
function* loginRequestSaga(action) {
try {
const data = yield call(userServices.fetchUser(action.credentials));
yield put(userActions.loginSucess(data));
} catch (e) {
console.log(e);
}
}
export const userSaga = {
loginRequestSaga,
};
预先感谢您的帮助
答案 0 :(得分:3)
我已经尝试回答您的确切问题,但是如果不查看其余代码就很难知道,因此请您原谅。
call(fn,args)需要一个函数,然后再输入一些args,因此您可能需要:
function* loginRequestSaga(action) {
try {
//next line has changed
const data = yield call(userServices.fetchUser, action.credentials);
yield put(userActions.loginSucess(data));
} catch (e) {
console.log(e);
}
}