Vue.js — How to load settings/data from the Server Before Initializing an App

Learn How to use mounted() Lifecycle Hook to load the settings

Bhargav Bachina
Bachina Labs

--

Photo by Mike van den Bos on Unsplash

In the web application, sometimes we have to load the data from the server before bootstrapping the front-end app. for example, we have to load the environment-specific settings before the front-end page loads so that we can pull the required files depending on the environment. Most of the time your initial loading page or home page depends on this data. Unless you have the data available you can’t load the page. We might end up with these scenarios like this very often.

For example, imagine a scenario where you need to show the user preferences on the landing page and you need to fetch these preferences from the server since each user might have different preferences based on their history. In this post, we will see how we can use mounted() Lifecycle Hook to fetch the data in the Vue applications.

  • Prerequisites
  • Example Project
  • What is a mounted Lifecycle Hook?
  • Using mounted Hook to fetch Settings
  • Demo
  • Summary
  • Conclusion

Prerequisites

--

--