I need to modify my object. please check below function
registerCus(item) { this.customer.code = 'B001'; this.customer.avCode = 'L01'; this.customer.ageCode = 'A1'; this.registrationService.customerRequest(item).subscribe(data => { }, error => { }); }
The item, included 3 values: code, avCode, ageCode. When I send the ‘item’ all three values pass to the service . According to my requirement I need to send only code and avCode. how can I modify ‘item’ before pass to service.
I am trying to do something like this,
registerCus(item) { item = this.customer.code, this.customer.avCode; this.registrationService.customerRequest(item).subscribe(data => { }, error => { }); }
Advertisement
Answer
You can use object de-structuring to achieve this behaviour without making any change in the code. You do this in your service method customerRequest
;
customerRequest ({code, avCode}) { console.log(code, avCode); }
Learn more about destructuring in JS.