I need to store data coming from an api in a variable. Only data that contains "true". I have given the API output below.
API Output Data
{
"BNG-JAY-137-003": false,
"BNG-JAY-137-004": true,
"BNG-JAY-137-005": false
}
Below is my function. In this I need to store only data which is true in a variable. Here selected_data is a variable which contains API data.
on(){
for(let key in this.selected_data) {
if(this.selected_data[key]) {
// here I need to store data which is true in an array.
}
}
}