Created
June 26, 2012 20:18
-
-
Save ntanya/2998641 to your computer and use it in GitHub Desktop.
Node.js data sharing between server and client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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