Skip to content

Instantly share code, notes, and snippets.

@ganeshkbhat
Last active October 4, 2018 06:31
Show Gist options
  • Save ganeshkbhat/4824af949e33157acc305491be52ef9f to your computer and use it in GitHub Desktop.
Save ganeshkbhat/4824af949e33157acc305491be52ef9f to your computer and use it in GitHub Desktop.
ExpressJS Series: Serving response
// Sends response as JSON
app.get("/", function(req, res) {
res.status(200)
.send({status:'running'});
});
// Sends response as XML using any XML2JS convertor
const xml2js = require('xml2js');
app.get("/", function(req, res) {
res.status(200)
.send(
xml2js({status:'running'});
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment