0

I am developing an angular app where, I have implemented an interceptor which adds token and content-type 'application/json' to the requests. Now there are are some apis where I need to post multipart data and hence content-type application/json wont be applicable there. How can I handle this scenario, as application/json is getting appended to all requests, hence overriding content type for multipart data api requests.

user9040429
  • 690
  • 1
  • 8
  • 29
  • Check this https://stackoverflow.com/questions/46469349/how-to-make-an-angular-module-to-ignore-http-interceptor-added-in-a-core-module/49047764 – Mridul Mar 30 '20 at 08:24
  • You can manually set `content-type` header to `multi-part/formdata` on those API calls, and then at your interceptor, set `content-type: application/json` for the request only if it has not been set already. – ar-m-an Mar 30 '20 at 08:28
  • @Mridul thanks for the link. Really liked the approach. – user9040429 Apr 02 '20 at 11:34
  • @ar-m-an I had already used this approach but it was not suitable for some scenarios – user9040429 Apr 02 '20 at 11:35

0 Answers0