Insert data from session to vue | vue add session
Inmyroutesfileiamgettingtheuserinthecurrentsessionandrenderingtheprofilehtml:app.get(/profile,isLoggedIn,function(req,res){res.render(profile.html,{user:req.user//gettheuseroutofsessionandpasstotemplate});});Theprofile.htmlwouldneedtheuserdatatodisplay,forexampletheusername.Thedatadisplayedinthehtmlisspecifiedinavuecomponent:varapp=newVue({el:#app,data:{message:HelloVue!},ready:function(){},methods:{}});Thecorrespondinghtmlelementwouldlooklikethis:
In my routes file i am getting the user in the current session and rendering the profile html:
app.get(/profile, isLoggedIn, function(req, res) { res.render(profile.html, { user : req.user // get the user out of session and pass to template }); });The profile.html would need the user data to display, for example the user name. The data displayed in the html is specified in a vue component:
var app = new Vue({ el: #app, data: { message: Hello Vue! }, ready: function() {}, methods: {} });The corresponding html element would look like this:
<div id="app"> {{ message }} </div>My issue is that i dont understand how to put the user data in the vue component? From the vue component, how do i retrieve user?