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

http response 拦截器导致无法获得response headers信息 #1

Open
longmain opened this issue May 24, 2018 · 2 comments
Open

http response 拦截器导致无法获得response headers信息 #1

longmain opened this issue May 24, 2018 · 2 comments

Comments

@longmain
Copy link

src/utils/api.js 中通过设置http response 拦截器,实现了对异常情况的处理。
但对于正常情况下,仅反回data,而不反回headers信息,对于今后逻辑中需要用到headers信息的情况是一个障碍。
在后台代码中通过ResultUtil仅设置了一些简单的headers信息,例如status code和message。但若是发生了错误情况,就不会返回data了,也不会用到result了;若是正常情况,所有的code均为200,设置这些信息也没用。况且,headers中的一些其他信息在通过拦截器时被拦截下来了。
建议返回整个response而不是仅返回data。

@Exrick
Copy link
Owner

Exrick commented Jun 1, 2018

springmvc @RestControllerAdvice 了解一下 后台是处理了的哈 @longmain

@longmain
Copy link
Author

longmain commented Jun 1, 2018

可能是我的issue提的有问题,把你的注意力都集中到异常处理上了。
我主要反映的问题是经过http response拦截后,如果没有异常,则仅返回了data。这样在整个前台都无法拿到headers里的内容了。

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

2 participants