0👍
Its best not to mix jQuery with Vue so here’s how you would do it using Axios https://github.com/axios/axios
methods: {
submit() {
const body = this.editingRecord.original
// make changes to body
axios.post( "backend_url", body )
.then(function(resp){
console.log(resp)
});
}
}
- [Vuejs]-405 (Method Not Allowed) – Laravel and Vue.Js
- [Vuejs]-Cannot run addEventListener (resize) in VueJS CLI to get screen width
0👍
Okay, I found the solution.
let vueObject = Object.entries(this.editingRecord.original)
for(const[key, value] of vueObject){
if(typeof value == 'object' && value !== null){
for(const [nestedKey, nestedValue] of Object.entries(value)){
result[nestedKey] = nestedValue
}
}else{
result[key] = value
}
}
console.log("resultObject is", result)
This way you can iterate over all properties including the properties of nested objects and reassign both key and value to a fresh, one-dimensional array.
- [Vuejs]-Input value that's binded with vue does not show up in the dom
- [Vuejs]-Laravel + Vue tutorial, not working as it should
Source:stackexchange.com