-
开启 MongoDB,输入数据 ( MongoDB安装运行 )
-
执行
npm install node app.js
-
使用 postman 调试请求
涉及到
_id
的请求,请求地址请根据数据库中的_id
调整
获取所有图书信息
http://localhost:3000/api/books
获取单种图书的信息
http://localhost:3000/api/book/58d38737d8eb6ee9811b9325
新增一种图书
{
"title": "JavaScript权威指南",
"genre": "计算机与互联网",
"description": "讲述的内容涵盖JavaScript语言本身,以及Web浏览器所实现的JavaScriptAPI",
"author": "弗兰纳根(David Flanagan)",
"publisher": "机械工业出版社",
"pages": "1004",
"image_url": "https://images-cn.ssl-images-amazon.com/images/I/51QWrj6sodL.jpg",
"buy_url": "https://www.amazon.cn/dp/B007VISQ1Y/"
}
更新一种图书的信息
{
"title": "JavaScript权威指南(第六版)",
"genre": "计算机与互联网",
"description": "讲述的内容涵盖JavaScript语言本身,以及Web浏览器所实现的JavaScriptAPI",
"author": "弗兰纳根(David Flanagan)",
"publisher": "机械工业出版社",
"pages": "1004",
"image_url": "https://images-cn.ssl-images-amazon.com/images/I/51QWrj6sodL.jpg",
"buy_url": "https://www.amazon.cn/dp/B007VISQ1Y/"
}
删除一种图书
http://localhost:3000/api/book/59056af8bf39f60ec6027486