updated — as the help provided was still not returning the desired results and thought that it could be in regards to how I presented the question
I am new to JSON and Struggling to work with this result in Javascript.
I am using this fetch to get a response that is returned as an object with nested objects and I am struggling to filter the results for the category with the value "mobile" only
any help would be greatly appreciated!
3
Answers
You can use lodash
pickBy
:If your response is an array of objects, where each object has a varying key and an associated object, you can use
Object.values
to grab the associated object, and check thecategory
of the first value.Assuming your test data is an array of objects (as current form is not correct),
and also assuming you will have more devices in the array, the following should work just fine:
Then you should get a list of matches as follows: