Search code examples
angularazure-application-insights

Angular Request & response body into application insights


I have seen a lot of articles on Request & response body into application insights for C# API's. I was wondering if anyone had any examples of doing this in angular. I already have insights working in my SPA solution but am not sure how to specifically get HTTP Response & Requests to show from the Angular SPA into insights.

I would be looking for something similar to this ( https://www.azureblue.io/how-to-log-http-request-body-with-asp-net-core-application-insights/) but for angular.


Solution

  • The C# examples just implement some middleware to handle requests/responses. This is easily achieved in angular using HttpInterceptors. I recommend reading up on how to implement these interceptors to handle the requests and responses as you see fit, as well as registering the HttpInterceptor in you app.module.ts providers array. https://angular.io/guide/http#intercepting-requests-and-responses