I've been working on optimizing my code to prevent making new http requests to my API every time I need to filter results.
Currently, I have an array called pageContent
that is populated with data from an API fetch when the page loads. Each object in the array looks something like this:
{
"title": "some title",
"description": "some random description",
"tags": [
"Tag1",
"Tag2",
"Tag3"
]
}
My goal is to filter this array when a specific button is clicked. The button passes a string value to the filter function. Here's what I currently have:
this.pageContent.filter(element => {
//ref represents the string value emitted by the filter button
return element.tags.includes(ref)
})
Unfortunately, this implementation isn't working as expected, and the array remains unchanged. Do you have any suggestions on how I can fix this issue?
Thank you for your help!