Skip to content

Instantly share code, notes, and snippets.

@ntanya
Created June 26, 2012 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntanya/2998641 to your computer and use it in GitHub Desktop.
Save ntanya/2998641 to your computer and use it in GitHub Desktop.
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