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

useAPI API 完善 #135

Closed
brickspert opened this issue Nov 7, 2019 · 4 comments
Closed

useAPI API 完善 #135

brickspert opened this issue Nov 7, 2019 · 4 comments
Assignees

Comments

@brickspert
Copy link
Collaborator

No description provided.

@xiexingen
Copy link

如何使用axios

@ttys026
Copy link
Collaborator

ttys026 commented Dec 12, 2019

如何使用axios

现在 useAPI 是基于 fetch 类请求库封装的,fetcher 类型是:
(url: string, options?: RequestInit) => Promise<any>
如果需要基于 axios,可以基于 useAsync 自己封装,方式上面可以参考 https://github.com/umijs/hooks/blob/master/src/useAPI/index.ts

@crashsol
Copy link

useApi, 如果请求返回的是undefined 会提示错误,需要添加 对res的判断
async () => { const res = await requestMethod(opt.url, opt.options); return res && res.json && typeof res.json === 'function' ? res.json() : res; },

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

5 participants
@xiexingen @brickspert @crashsol @ttys026 and others