[Vuejs]-Is there any other way to fetch data instead of prefetch in vue hacker news

0👍

Yes there is.

You can do whatever you want in each component’s own mounted/created/etc. hooks. This would most likely be an appropriate place to fetch data from the network and then display it to the user. You would probably show a loading spinner by default and disable it when the data arrives. You would store the received data in the component’s local data.

Without Vuex or other state management solutions and only using components, however, the fetched data will be local to your component. Thus switching out the component loses the data and will require a new network fetch and so on.

Leave a comment