0👍
You just need to update data after patch method
export default {
name: "HelloWorld",
setup() {
const state = reactive({
numbers: [],
inputValue: 1,
pk: 1,
});
const updateData = () => {
return axios
.get("http://127.0.0.1:8000/api/numbers-list/")
.then((res) => (state.numbers = res.data));
}
function changeNumber() {
const data = {
number: state.inputValue,
};
console.log(data);
axios
.patch(`http://127.0.0.1:8000/api/number-update/${state.pk}/`, data)
.then(updateData);
}
onMounted(updateData);
return {
changeNumber,
state,
};
},
};
- [Vuejs]-Error saying variable is not defined when it is clearly defined
- [Vuejs]-How to call a method only once in v-for iteration in Vue?
Source:stackexchange.com