Last active
October 4, 2018 06:31
-
-
Save ganeshkbhat/4824af949e33157acc305491be52ef9f to your computer and use it in GitHub Desktop.
ExpressJS Series: Serving response
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
// 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