I am new to Vue. While making this component, I ran into difficulty here.
I use the following code to make an AJAX request to the API which returns an array:
The problem is,this.tickets
is set to aProxy
object, not theArray
I get from the API.
What am I doing wrong here?
If you want responsive information, use toRawhttps://vuejs.org/api/reactivity-advanced.html#toraw
Or if you don't want the ref wrapper to surround your information, use unref
https://vuejs.org/api/reactivity-utilities.html#unref
Items in data like your tickets are converted into observable objects. This is for responsiveness (automatic re-rendering of the UI and other features). This is expected, the returned object should work like an array.
Check out the reactivity documentation as you need to interact with the array in a specific pattern or it won't update on the UI:https://v3.vuejs.org/guide/reactivity-fundamentals.html
If you don't want responsiveness - maybe you never update tickets on the client side and just want to display them - you can use the Object.freeze() method on response.data.