753 B
753 B
title |
---|
Serve JSON on a Specific Route |
Serve JSON on a Specific Route
It is rather simple to serve a json object with node (at the '/json' route), if we want to deliver a message and give it the value "Hello World," we can do so like this:
app.get("/json", function(req, res) {
res.json({"message": "Hello World"});
});