I have a json object returned from a SQL query. I want to filter out the json key before sending back to the front end. If the key is true, return back to the front end is what I am looking for.
In my server file I have this line.
let returned_data = Object.entries(queried_data[0]).forEach((key, value) => {
return value === true ? key : null
})
res.json(returned_data)
This is an example of my returned json after SQL querying.
[{first_name: 'testing', has_apple: true, has_pear: true, has_beans: false}]
I am expecting the returned_data
to have ['has_apple', 'has_pear']
. Right now I am getting undefined for returned_data