Angular subscribe issues

32 views Asked by At

I am converting subscribes to not be deprecated and use the next:, error:, and complete.

Testing I am not able to populate the options, input etc to complete the form and submit. "Subscribe Deprecated"

A lot of my conversions are not passing testing. I am not sure why.

Angular CLI: 15.2.10
Node: 16.14.2
Package Manager: npm 9.7.2
OS: win32 x64

Angular: 15.2.10
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.10
@angular-devkit/build-angular   15.2.10
@angular-devkit/core            15.2.10
@angular-devkit/schematics      15.2.10
@angular/cdk                    15.2.9
@angular/material               15.2.9
@schematics/angular             15.2.10
ng-packagr                      15.2.2
rxjs                            7.8.1
typescript                      4.9.5
webpack                         5.89.0

Original code:

getBopsOrders() {
    this.http.get(this.config.data.BopsOrdersUrl).subscribe((data: any) => {
        const settings = {
          callPath: data.response.query_string,
          firstMessage: data.response.action_message,
          dontCloseTag: null,
          contactSupportTag: 'as-contactsupport',
          closeButton: 'as-close'
        }
        this.actionScriptService.actionscriptInit(settings).then((bopsorders: any) => {
          this.retrievedAllOrders.getBopsOrders = true;
          console.log(typeof(bopsorders), bopsorders);
          const json = JSON.parse(bopsorders);
          this.storeArray = json;
          
          this.bopsorders = json.orders.filter((order: any) => {
            return order.file_seq_nbr == this.fileSeqNbr;
          });

        }).catch(error => {
          console.log(error);
          this.retrievedAllOrders.getBopsOrders = true;
        });
    }, (error) => {
      console.log(error);
      this.retrievedAllOrders.getBopsOrders = true;
    });
  }

Edited:

getBopsOrders() {
    this.http.get(this.config.data.BopsOrdersUrl).subscribe({
      next: (data: any) => {
        const settings = {
          callPath: data.response.query_string,
          firstMessage: data.response.action_message,
          dontCloseTag: null,
          contactSupportTag: 'as-contactsupport',
          closeButton: 'as-close'
        }
        this.actionScriptService.actionscriptInit(settings).then((bopsorders: any) => {
          this.retrievedAllOrders.getBopsOrders = true;
          console.log(typeof(bopsorders), bopsorders);
          const json = JSON.parse(bopsorders);
          this.storeArray = json;
          
          this.bopsorders = json.orders.filter((order: any) => {
            return order.file_seq_nbr == this.fileSeqNbr;
          });

        }).catch(error => {
          console.log(error);
          this.retrievedAllOrders.getBopsOrders = true;
        });
      }, error: (error) => {
        console.log(error);
        this.retrievedAllOrders.getBopsOrders = true;
      },
    complete: () {
        console.log('completed subscribe');
}
    })
  }

What would need to be changed so this works as it did before with the deprecation warnings?

0

There are 0 answers