I am having one form and will get values from the input. On button click, I am forming one object like below,
let data = filter : {
metadata : {
name: apple,
type: fruits
},
match_attributes: {
value : code_1
}
}
Here, I need to remove the object "match_attributes", if "value" key is empty. My expected output will be like below,
let data = filter : {
metadata : {
name: apple,
type: fruits
}
}
I tried by something like this but not worked,
let test = {};
if(this.getValue) {
test = match_attributes : {
value : this.getValue
}
}
filter : {
match_metadata : {
name: this.name,
type: this.type
},
test
}
My Output :
let data = filter : {
metadata : {
name: this.fruitName,
type: this.fruitType
},
{ }
}
Is there anyway to do this. Cheers.
[<>]snippet editor and make a minimal reproducible examplethis.getValuedelete->delete data.filter.match_attributes