I'm just starting out with Vue.js and I'm struggling to grasp how it all works. I have a function that sends data to the server and receives a response using axios. However, when I try to display the response using a variable, something seems to be going wrong.
Here's a snippet of my HTML template:
<p v-if="text"> {{ text }} </p>
And here's my Vue code:
const text = ref(undefined);
axios.post('api', anotherVar).then(
function (response) {
response.data.error ? (text.value = response.data.error, console.log(text.value)) : (console.log('Everything is OK'));
});