arthurfiorette / axios-cache-interceptor

📬 Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!
https://axios-cache-interceptor.js.org
MIT License
698 stars 58 forks source link

Documentation: Note Vue behavior when using modified cached arrays #932

Closed merlinz01 closed 2 weeks ago

merlinz01 commented 2 weeks ago

What happened?

I implemented effectively the same thing in my Vue app as documented here. But the new data was not showing up in my table. I finally discovered that Vue does not update the UI if the object assigned to a ref's value is the same object as was there already. Everything was actually working correctly, but since the cached array was the same object as the original (although appended to), the UI was not updating.

So instead of writing this:

items.value = (await axios.get(url)).data

I changed it to this:

items.value = [...(await axios.get(url)).data]

and it works correctly.

I assume that this behavior is expected, so can we make a note of it in the documentation?

axios-cache-interceptor version

1.6.0

Node / Browser Version

N/A

Axios Version

1.7.7

What storage is being used

Memory Storage

Relevant debugging log output

N/A
arthurfiorette commented 2 weeks ago

Hi @merlinz01, thanks for the discovery!

Would you like to PR this doc improvement?

merlinz01 commented 2 weeks ago

Sure.