Hey gang,
I was using CodePen and I wrote a very basic (that's my level mostly) on pulling some JSON from (my) GitHub and it worked last I played with it, but now I want to just mess around with it on my computer; yes I've installed NodeJS btw. With NodeJS installed I thought I could just write an HTML page and include the JS like a normal webpage and then run it.
This is the JSON and URL I use to pull too. http://codepen.io/misterhtmlcss/pen/wWzRVJ
Can anyone give me an idea what I need to do on my computer (mac osx) that's different? Or a good tutorial?
I'd just like to mess around exclusively on my laptop and build, rewrite and widen this code from useless and a basic call to something more and I'm not sure what the minimum foundation is to get started.
Simplest solution that allows me to get started and working would be most appreciated. The perfect long-term solution that requires a whole bunch of additional learning while appreciated isn't today or this months goal.
Please and Thank you!!
Zach Sosana
all things javascript
Roger ol buddy ol pal, hope all is well my friend :)
I recommend using express and bodyparser middleware for basic setup of your mini app displaying your json.
To get the json file's content :
var foo = require('./path/to/your/file.json');To send the json to your view:
function getJson(req, res, next){ res.send(foo); }While this will work, do take note that require calls are cached and will return the same object on each subsequent call. Any change you make to the .json file when the server is running will not be reflected in subsequent responses from the server.
hit me up on gitter calgary chat room so we can chat more and I can help you out bra. Also I like your all things javascript @misterhtmlcss and @equimper repo wink wink nodge nodge ;)