I am sending object data to some API. I have many states and not every one is required every time, so I want to remove any properties from the object that are null or an empty string. How can I do this?
export default {
methods: {
sendData() {
axios
.post("api", this.$store.state.data)
.then((response) => console.log(response))
.catch((error) => console.log(error));
console.log(this.$store.state.data);
},
},
mounted() {
this.sendData();
},
};
Here, where I have store state data, I need to send only the filled values and not everything with empty values too.