How to filter specific key + values in Javascript
I am working with the swapi API. I want to return an object but only specific entries.
For example;
Obj = { name: "Luke", age: 10, gender: "male"}
But I specifically want to return a new object which is the name and gender with it's key name and value.
My goal is to return them into a table but possibly have the option to have advanced filter. So user can return for name and age or more entries.
10 Replies
this returns an array of person objects that match the criterea
I'm not sure, I don't want the gender male and want the results of the key gender
So not just the values but it's actually key so I can print the key in a table header
please give me an example of the data you have and the result you want
Example
currenlt in my react app, i search for the characters name, "luke" which will render a table with luke skywalker in the name column
and other properties in the object in api
How do i only return specific columns? the user does not need to see all the object properies as that would be a big table (over scrolling etc)
@MarkBoots
https://github.com/Saf98/SWAPI-ReactJS/blob/feature/refactor-table-filter/src/components/Results.jsx
GitHub
SWAPI-ReactJS/src/components/Results.jsx at feature/refactor-table-...
Contribute to Saf98/SWAPI-ReactJS development by creating an account on GitHub.
cuurent code
i forgot all about destructering
Thank you!
Well that would be the same hard coding, i think what I should do is to render everything and hide them using css
That's anyway I appreciate it