英文:
How to apply interceptor in Angular only to POST requests?
问题
在Angular中,是否可以仅针对POST请求应用拦截器?
英文:
Is it possible to apply interceptors in Angular only to POST requests?
答案1
得分: 2
在您的拦截器的intercept
方法中,将有一个req
参数,其类型为HttpRequest
。这个类有一个属性,method
,如果请求的HTTP方法是POST
,则其值将为post
。
英文:
Within the intercept
method of your interceptor, will have a req
parameter, which is of type HttpRequest
. This class has a property, method
which will be post
if the HTTP method of the request was POST
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论