Илья Лахин
https://vk.com/id925174
Skype: eliah.lakhin
Запрос
Ответ
<html>
<head>
<title>Book Store</title>
</head>
<body>
<h1>List of book</h1>
<ul ng-repeat="book in books">
<li> {{ book.title }} </li>
</ul>
<h1>Add a book</h1>
<form>
Title: <input type="text" ng-model="newBook.title">
Text: <textarea ng-model="newBook.content"></textarea>
<button ng-click="send()">Add<button>
</form>
</body>
</html>
import Promise from 'bluebird';
import database from './app/database';
router = [
{
route: '/api/book/:id',
method: 'get',
controller: (req, res) => {
const bookId = req.id;
database.books.fetch({ id: bookId }).then((book) => {
res.send(book);
});
}
},
{
route: '/api/book/',
method: 'post',
controller: (req, res) => {
const payload = {
title: req.body.title,
text: req.body.content
};
database.books.create(payload).then((book) => {
res.send(book.id);
});
}
},
];
id | title | content |
---|---|---|
1 | Dimension of Miracles, Robert Sheckley | Lorem ipsum dolor sit amet |
2 | Starship Troopers, Robert A. Heinlein | Lorem ipsum dolor sit amet |
4 | King Lear, William Shakespeare | Lorem ipsum dolor sit amet |
5 | 1984, George Orwel | Lorem ipsum dolor sit amet |
https://vk.com/id925174
Skype: eliah.lakhin