Talking about subcribe precautions for angular2's http request to return results

  • 2021-07-26 06:03:05
  • OfStack

Examples are as follows:


this.monitorSer.getVehicleLonAndLat(vehicleIds)
 .subscribe(
  data => {
   // Will data Under data String is converted to vehdata Array 
   this.vehData=JSON.parse(data.data);
   // Function realization 
   this.loadOverLay();
  },

  error => this.errorMessage = <any>error

);// Error handling 

subscribe () processes asynchronously, and if you need to use the returned data, you'd better write the method in it.


Related articles: