I am currently attempting to retrieve the HTTP requests before they are actually sent to the server.
Initially, I tried creating a HttpIntercepter like this:
@Injectable()
export class HttpLoggingInterceptorProvider implements HttpInterceptor
{
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
{
console.log('Request To Be Logged:');
console.dir(req);
if(req.body)
{
try
{
let formData = <FormData>req.body;
if(formData.has('id_front'))
console.log(formData.get('id_front'));
if(formData.has('id_back'))
console.log(formData.get('id_back'));
}
catch(err)
{
}
}
return next.handle(req);
}
While this method works well for now, it is not exactly what I am looking for. My goal is to access the final composed request in raw text form rather than objects.
Currently, the console output appears like this
As you can see, I'm unable to extract any meaningful information from it. It's hard to determine the number or content of values that have been set.
However, by programmatically requesting the body's contents, I am able to retrieve the values as shown below:
let formData = <FormData>req.body;
if(formData.has('id_front'))
console.log(formData.get('id_front'));
if(formData.has('id_back'))
console.log(formData.get('id_back'));
At least, I now know something exists within the body other than its FormData type...
My main inquiry:
Is there a way for me to capture the raw composed request that will eventually be dispatched to the server?