I'm working with an API that has a large data set that filters products by type, category, etc.
In each JSON object, for each item in the array, there is a key called code:`` followed by a string (example: "FRULE137980". Each sub category also have arrays with this key and rule. In the sub category, in addition to the
code:key, there is a
productCount```
This is what the URL looks like when you filter down your product selection.
"https://www.somewebsite.com/prodouct/product-category--CAT33-c?sellingAidsFilter=SRULE4663&ruleFilter=FRULE137980%2CFRULE1933147%2CFRULE1914521%2CFRULE1914663"
This returns the product count in each applied filter.
I am working with a 6 step form and have to filter down the productCount
in each step. How do I concatenate the rules in each step to return the correct productCount
? I've only been able to successfully do this in the second step using this method:
const changeProductCount = () => {
let sum = 0;
changeProductCount.forEach(function () {
let calculation =
filters.sellingAidsFilter - content.content.facetFilters[0];
sum += calculation;
});
return sum;
};
However, this seems redudant to keep have to do a calculation in each step. Sorry for the n00b question, but thanks in advance.
question from:
https://stackoverflow.com/questions/65951115/concatenating-json-rules-to-filter-data 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…