Search code examples
javascriptangulartypescriptapiswagger-codegen

Javascript: What is reportProgress in Http Services?


What does reportProgress do in Javascript, specifically we are using Angular Typescript. Trying to locate document information on this.

return this.httpClient.request<ProductResponse>('get',`${this.basePath}/api/Productcy/GetProductBNumber`,
    {
        params: queryParameters,
        withCredentials: this.configuration.withCredentials,
        headers: headers,
        observe: observe,
        reportProgress: reportProgress
    }
);

Background: Using Angular to call Net Core APIs, using Swagger Codegen IO Proxy Generator.


Solution

  • You need to use reportProgress: true to show some progress of any HTTP request. If you want to see all events, including the progress of transfers you need to use observe: 'events' option as well and return an Observable of type HttpEvent. Then you can catch all the events(DownloadProgress, Response..etc) in the component method. Find more details see https://angular.io/guide/http#listening-to-progress-events