I am facing an issue with fetching the id inside the Apiservice despite being able to get it in the console. Can anyone provide assistance on how to solve this problem?
TS:
deleteProduct(index,product) {
var token = this.auth.getAccessTokenId();
this.products.splice(index, 1);
var del = this.products.splice(index, 1);
del.map(function(product) {
var Id = product.id;
console.log(Id);
})
this.ApiService
.deleteProducts(this.Id,token)
.subscribe(
products => {
console.log(products);
this.products = products;
}, error => {
//console.log(error);
})
}
Although console.log(Id); works properly, the value is not being passed to ApiService.