I want to put the data from API to Vue state. What is the quick approach to do this?
getProjectData(id) {
axios.get(`/api/project/${id}`).then((res) => {
console.log(res)
/* I don't want to manually assign the value one by one (since the name is the same, there should be a quick way */
this.formState.name = res.data.projects.name
this.formState.stage = res.data.projects.stage
this.formState.status = res.data.projects.status
this.formState.description = res.data.projects.description
this.formState.stations = res.data.projects.stations
});
},
Object.assign(this.formState, res.data.projects)