[错误:呼叫:类型{context,fn}的参数未定义或null`fn`]

发布于 2025-02-01 12:25:43 字数 631 浏览 3 评论 0原文

我在应用程序中使用Saga Redux,当我尝试向我的API请求时,我会遇到以下错误,

èrro [Error:call: argument of type {context,fn} has undefined or null `fn`] -- > and 
 << -- --> Possible unhandled Promise rejection (id:0).
try {
  const date = yield call(cloudfy.requestExtractList(), {
    DadosConta,
  });

  console.log('test', date);
  yield put(ActionCreators.requestExtractList(response.data));
} catch (error) {
  console.log(error);
}

如果我在requestExtractList上删除(),则触发错误响应 const date =收益呼叫(cloudfy.requestextractList,{adosconta,})>

I'm using saga redux in my application, and I'm getting the following error when I try to make a request to my api the error is:

èrro [Error:call: argument of type {context,fn} has undefined or null `fn`] -- > and 
 << -- --> Possible unhandled Promise rejection (id:0).
try {
  const date = yield call(cloudfy.requestExtractList(), {
    DadosConta,
  });

  console.log('test', date);
  yield put(ActionCreators.requestExtractList(response.data));
} catch (error) {
  console.log(error);
}

Fires error response if I remove the () at requestExtractList
const date = yield call(cloudfy.requestExtractList, { DadosConta, })

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2025-02-08 12:25:43

不确定requestExtractList是否需要cloudfy上下文,如果是这样,请尝试:

const date = yield call([cloudfy, cloudfy.requestExtractList], { DadosConta, })

如果您再次获得错误响应,则该问题在您发送到端点的数据中,而不是传奇API。

此外,如果您仅调用一个普通功能,则不一定需要使用呼叫效果。传奇的产量可以直接处理承诺。因此,您可以做:

const date = yield cloudfy.requestExtractList({ DadosConta, })

Not sure if requestExtractList needs the cloudfy context, if so try:

const date = yield call([cloudfy, cloudfy.requestExtractList], { DadosConta, })

If you again get an error reponse it means the problem is in the data you send to the endpoint, not the saga api.

Additionally, if you are calling just a normal function you don't necessarily need to use the call effect. Saga's yield can handle promises directly. So you can do just:

const date = yield cloudfy.requestExtractList({ DadosConta, })
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文