如何在Angular中仅对POST请求应用拦截器?

huangapple go评论59阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年8月4日 04:06:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76831318.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定