Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当我使用ahooks 的 useRequest 时 报错--Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then') #2351

Open
chenJJ-88 opened this issue Oct 30, 2023 · 7 comments

Comments

@chenJJ-88
Copy link

chenJJ-88 commented Oct 30, 2023

image
image
image
请问一下这个怎么处理呢????

@Wang-yubo
Copy link

options里面写onSuccess函数处理返回参数

@chenJJ-88
Copy link
Author

options里面写onSuccess函数处理返回参数

方便详细说一下吗,不是很理解你说的,这个和处理返回蚕食有什么问题呢

@crazylxr
Copy link
Collaborator

@chenJJ-88 请提供一个 demo 呢

@crazylxr crazylxr added the 🤔 Need Reproduce We cannot reproduce your problem label Feb 27, 2024
Copy link

Hello @chenJJ-88. Please provide a online reproduction by forking this link https://codesandbox.io/s/ok2fe or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @chenJJ-88, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

@liuyib
Copy link
Collaborator

liuyib commented Feb 27, 2024

image

看截图这个目录结构和文件名,感觉不像是 v3 的 ahooks,像是 v2 版本的。应该是用的这个包:https://www.npmjs.com/package/@ahooksjs/use-request

@liuyib
Copy link
Collaborator

liuyib commented Feb 27, 2024

楼主用了 v2 的这个用法:

https://ahooks-v2.js.org/zh-CN/hooks/async#%E9%9B%86%E6%88%90%E8%AF%B7%E6%B1%82%E5%BA%93

image

然后他的 service 传函数时,返回值出现了 undefined,导致:s.then 取值报错:

image

@chenJJ-88 你应该调整 service 函数的返回值,不能返回假值(null, undefined)

@liuyib
Copy link
Collaborator

liuyib commented Feb 27, 2024

另外 v2 已经不再维护,可以的话请升级最新版本

@liuyib liuyib removed the 🤔 Need Reproduce We cannot reproduce your problem label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants