Skip to content

Instantly share code, notes, and snippets.

@bscott
Created November 4, 2013 16:53
Show Gist options
  • Select an option

  • Save bscott/7305601 to your computer and use it in GitHub Desktop.

Select an option

Save bscott/7305601 to your computer and use it in GitHub Desktop.
http://localhost:8081/chef?type=json
app.get('/chef', function(req, res) {
var conf = appUtil.parseConfig();
appUtil.getChefNodes(function(result) {
if (req.query.type && (req.query.type == 'xml')) {
res.set('Content-Type', 'text/xml');
res.render('xml.ejs', {baseUrl: 'http://localhost:8080', user: conf['chef']['node_name'], org: conf['chef']['organization'], nodeItems:result});
} else if (req.query.type == 'json') {
res.set('Content-Type', 'application/json');
res.json('nodeItems:result');
} else {
res.render('chef.ejs', {user: conf['chef']['node_name'], org: conf['chef']['organization'], nodeItems:result});
}
});
});
@dephee

dephee commented Nov 4, 2013

Copy link
Copy Markdown

oh, line 9, should be res.json(result);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment