async onSubmitConditionDuration() {
var param = (this.state.health_condition+"_personal_age")
try {
axios.patch(URL,
{
param: this.state.condition_duration, //param is a variable that represents a field name at the endpoint(URL)
})
.then((response)=>{
console.log(response.status);
})
.catch((errors) => {
console.log(errors);
})
}
catch(errors){
console.log(errors);
}
}
I'm trying to have field names as variable in the json body of my request so that fields can be dynamically updated based on variables' values. By using the above syntax ,the patch request fails to update the field represented by the value stored in 'param'.
How can this be done in Javascript?
I'm working in a react native app