I have a django application where I have an area that is made in Vue.js. I would like to know if it is possible to set parameters at the time of initialization of the Vue.js app in HTML. For example a token where the VueApp can use to authenticate and fetch some apis in django.
Today it is being done like this:
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script>
window.config = {{vue_config | safe}};
</script>
<script type="text/javascript" src="{% static 'js/app.js' %}"></script>
</body>
And inside the VueApp I get the configs from window.config
Is there a better way to do this?