freeCodeCamp/guide/english/certifications/apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route/index.md

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"});
  });

Help our community expand these hints and guides.