I have an application, and part of it is to log in to Twitter. After a successful login, I usually pass the user data to the template
app.get('/', function(req, res, next) {
log("The Home page has the user info: ", req.session.user);
res.render('pages/home', {
app: 'home',
user: req.session.user || ''
});
});
And then you can display the template based on the data user.
But in React, how do you pass such data to a component after logging in?
I am thinking of direct data placement in the browser, but I am not sure about that.
<script type="javascript">
var user = #{user}
</script>
What do you think??? Thank.
source
share