Using Axios.patch to modify data in an API. Here's a glimpse of the API structure:
"email": "string",
"phoneNumber": "string",
"mobileNumber": "string",
"temporaryAddress": {
"address1": "string",
"address2": "string",
"address3": "string",
"address4": "string",
}
It's straightforward when updating values except for when trying to update values within an object, like addresses. The syntax seems to be causing trouble. How can I edit a value inside an object? Specifically, I want to change address1, address2, etc.
I've experimented with different approaches but none seem to work. For example: "address: this.myAddress", "address: this.myAddress.address1", and "address1: this.myAddress" have all failed to update the values.
updateCustomer() {
this.$axios.$patch('http://localhost:8381/customer/v3/PRIVATE/' + this.customerData.id + '/?auditUser=Updatus', {
lastName: this.lName,
phoneNumber: this.phoneNr,
email: this.eMail,
mobileNumber: this.mobileNr,
firstName: this.fName,
address.adress1: this.myAddress
}, {
headers: {
'Authorization': 'Basic YXBpdXNlcjpwYXNzd29yZA==',
'Content-Type': 'application/json',
},
})
.then(response => {
alert("Information successfully changed!")
this.updateCheck = false;
})
error => {
alert("Type in the information correctly!");
console.log("update error test");
return false;
}
}
The goal is to update the value of address1 based on user input, but so far I'm encountering errors or the value remains unchanged.
Tried another approach: "address: {address1: "blabla 2", address2: "blablabla 3", address3: "tester 4", address4: "mehmeh 5"}". Although it compiled, it resulted in a 400 "Bad Request" error. Need guidance on the correct method.