Router api/todo-items

This commit is contained in:
2024-04-22 11:45:11 +03:00
parent 14456c5ab4
commit 6ad588e3ee
2 changed files with 22 additions and 0 deletions

View File

@@ -9,6 +9,11 @@ app.use((req, res, next) => {
next();
});
const todoItems = require('./todo-items.json');
app.get('/api/todo-items', (req, res) => {
res.json({ data: todoItems });
});
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});

View File

@@ -0,0 +1,17 @@
[
{
"id": 1,
"text": "Изучить NodeJS",
"done": true
},
{
"id": 2,
"text": "Изучить ReactJS",
"done": true
},
{
"id": 3,
"text": "Написать приложение",
"done": false
}
]