Router api/todo-items
This commit is contained in:
@@ -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}`);
|
||||
});
|
||||
|
||||
17
app/backend/todo-items.json
Normal file
17
app/backend/todo-items.json
Normal file
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"text": "Изучить NodeJS",
|
||||
"done": true
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"text": "Изучить ReactJS",
|
||||
"done": true
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"text": "Написать приложение",
|
||||
"done": false
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user