I am looking to achieve a specific behavior in my project: depending on a condition stored in my database, I want to load a particular vue.component instead of another. For example, within a file named discover.js
, there is the following code:
Vue.component(
'discover-component',
require('./components/DiscoverComponent.vue').default
);
The goal is to only call the DiscoverComponent.vue
if a specific boolean value is set to true for the user in the database. Otherwise, another component should be called. Here is a pseudocode example:
If flag is true:
Vue.component(
'discover-component',
require('./components/TrueDiscoverComponent.vue').default
);
Else:
Vue.component(
'discover-component',
require('./components/FalseDiscoverComponent.vue').default
);
My question is whether it is advisable to use an AJAX call in the .js file to retrieve the value of the flag
. Is this practice considered acceptable, or would it be better to handle such data retrieval within a controller instead?