I'm new to vue and trying to work it with django. I have a field called status that uses boolean field and set the default=False. I'm trying to update the data in the backend by onclick. When i click the div, data will emit to parent and update the status to !status.
Child:
<div @click="$emit('update-status', this.task)">{{ task.status}} </div>
Parent:
<Task v-for="task in tasks"
:key="task.slug"
:task="task"
:slug="task.slug"
@update-status="updateStatus"/>
async updateStatus(task) {
let endpoint = `/api/v1/tasks/${task.slug}/`;
const response = await axios.put(endpoint, {
status: !task.status,
});
}
It updates once and it keeps returning the same value True when I keep on clicking (it should always return opposite of status). I have to manually refresh my browser, so when I click it again it will return False.