I can't update object field value in array in this part.
this.wiredProducts[0].Price__c = this.selectedRate;
I can get this value but can't do anything with it. It throws such error:
[NoErrorObjectAvailable] Script error.
So may be someone knows something about this issue. The code is below.
import { LightningElement, wire, track, api } from 'lwc';
import getActiveProducts from '@salesforce/apex/GetActiveProducts.getSearchedProducts';
export default class IterationInLwc extends LightningElement {
@api searchedName;
@api searchedPrice;
wiredProducts;
rates;
@api selectedRate = 1;
@track searchedProducts;
@track error;
@wire(getActiveProducts)
wiredProduct({ error, data }) {
if (data) {
console.log(data);
this.wiredProducts = data.productList;
this.rates = data.rates;
this.searchedProducts = this.wiredProducts;
console.log(this.prices);
console.log(this.searchedProducts);
} else if (error) {
this.error = error;
}
}
handleSearchByName(event){
this.searchedName = event.target.value;
this.searchedProducts = this.wiredProducts.filter
(product => product.Name.includes(this.searchedName) && product.Price__c >= this.searchedPrice);
}
handleSearchByPrice(event){
this.searchedPrice = parseFloat(event.target.value);
this.searchedProducts = this.wiredProducts.filter
(product => product.Name.includes(this.searchedName) && product.Price__c >= this.searchedPrice);
}
handleMenuSelect(event) {
this.selectedRate = event.detail.value;
this.wiredProducts[0].Price__c = this.selectedRate;
}
}