Currently, I have implemented an Angular HTTP post request with the following parameters:
this.http
.post<{ body: any }>(environment.api.file.upload, reqBody, {
reportProgress: true,
observe: 'events',
})
.subscribe((ev: HttpEvent<{ body: any }>) => {
switch (ev.type) {
case 1:
this.progress = ev.loaded / ev.total;
break;
}
});
However, upon trying to access the value of `ev.loaded`, it results in the error message:
Property 'loaded' does not exist on type 'HttpSentEvent'
The condition ev.type === 1
is intended to only process HttpProgressEvent, but it doesn't work as expected.
Is there a way to utilize the `HttpEvent` type without encountering this error?