[Angular] Progress HTTP Events with 'HttpRequest'
New use case that is supported by the HTTP client is Progress events. To receive these events, we create our HTTP request manually in the following way:
longRequest() { const request = new HttpRequest( "POST", "/api/test-request", {}, {reportProgress: true}); this.http.request(request) .subscribe( event => { if (event.type === HttpEventType.DownloadProgress) { console.log("Download progress event", event); } if (event.type === HttpEventType.UploadProgress) { console.log("Upload progress event", event); } if (event.type === HttpEventType.Response) { console.log("response received...", event.body); } } ); }
HttpEventType can be found here: link