Skip to content

Instantly share code, notes, and snippets.

@ntanya
Created Jun 26, 2012
Embed
What would you like to do?
Node.js data sharing between server and client
//Client side
app.get('/trends', function(req, res){
twitterProcessor.getTrends( function(error, trendData){
res.render('trends.jade',{ locals: {
trends:trendData // here's the data you pass to client
}
});
});
});
//Client side
script(type='text/javascript')
var data =!{JSON.stringify(trends)}
//And this is how it will see in the browser
<script type="text/javascript">
var data = []; // your data
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment