Files

17 lines
516 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Serve JSON on a Specific Route
---
## Serve JSON on a Specific Route
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
It is rather simple to serve a JSON object with Node (at the `/json` route), if we want to deliver an object containing a key `message` and with the value `"Hello json"` we can do so as indicated:
2018-10-12 15:37:13 -04:00
```javascript
app.get("/json", (req, res) => {
res.json({
"message": "Hello json"
});
});
2018-10-12 15:37:13 -04:00
```