-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Axios请求格式化请求参数一个小问题 #850
Comments
所有的参数一律通过params提交,无论是GET还是POST、PUT。如果有params以及data同时存在的场景,请自己按照defHttp的参考简单封装一个axios实例。 |
OK,理解错了项目中axios的逻辑 |
修改了一下你提到的地方,保持原用法不变,但是兼容你说的用法。非GET请求时,如果同时存在data和params,不会丢弃data数据;如果只存在params,仍然像之前那样会被视作data。 |
mynetfan
added a commit
that referenced
this issue
Jul 3, 2021
当非GET请求并且同时存在data和params,不再忽略data。使defHttp的用法习惯接近axios原生配置 fixed: #850
ethan-wilson-1291
pushed a commit
to ethan-wilson-1291/vue-vben-admin
that referenced
this issue
Feb 2, 2025
当非GET请求并且同时存在data和params,不再忽略data。使defHttp的用法习惯接近axios原生配置 fixed: vbenjs#850
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
不知道怎么描述,直接贴出问题点所在吧,在beforeRequestHook中对于所有非GET请求参数进行格式化,如果没有传递params参数,例如 POST、PUT请求,那么传递的data数据会被覆盖
https://github.com/anncwb/vue-vben-admin/blob/8819af083c80389453153c2b5f84b3bd1e408ba5/src/utils/http/axios/index.ts#L103-L110
问题复现:
此时观察控制台网络请求,请求体中Request Payload为空
The text was updated successfully, but these errors were encountered: