I'm fairly new to the composition API but it's been somewhat straight forward so far.
I'm making an Axios call that is returning some data;
const transaction = ref({});
let pbl = reactive({});
const getPayByLinkTransaction = () => {
axios({
method: "get",
url: "pay-by-link",
params: {
merchantUuid: import.meta.env.VITE_MERCHANT_UUID,
uuid: route.params.uuid,
},
})
.then((res) => {
transaction.value = res.data;
pbl = res.data;
})
.catch((e) => {
console.log(e);
});
}
getPayByLinkTransaction();
Then I have the following textfield:
<v-text-field v-model="transaction.reference" variant="solo" class="mb-1"
:rules="config?.fields?.reference?.required ? required : []"></v-text-field>
PBL - {{ pbl.reference }} <br>
Transaction - {{ transaction.reference }}
The reference key contains John Doe to start off with.
What's strange is that when I start typing into the textfield, it's changing reference in both the transaction and pbl object.
As the v-model is attached to transaction.reference, should it not only change the variable in the transaction object?
Why is the pbl object changing too?
What I'm after are two objects where one contains the original data and the other contains modified data if the user were to amend any details.