Files

18 lines
406 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
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
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
```