I struggle to filter an API JSON response by a key->value.
I fetch the API containing about 3000 instances, and I struggle to get the filtering functionality working. Example response:
{
"name": "Rolex",
"id": "123",
"type": "Expensive",
"image": "imgURL1"
},
{
"name": "Omega",
"id": "456",
"type": "Cheap",
"image": "imgURL2"
},
How can I filter the data by value field “type”->contains/includes/equals->“Cheap”?
I cannot manipulate the primary response since I’d like to filter this differently on the same page. The plugIn Simple Filter doesn’t seem to work either… I’m doing something stupid wrong here…
This is pretty simple to achieve in PHP or JS code (NUXT code):
watchesValue.value = filteredWatches.filter(watches => watches.type?.includes('Cheap'));
I tried to figure it out for a few days but realized I needed help getting this running. Or maybe this have to be done in “Custom Code”…
Any help to point me in the right direction is much appreciated