node项目启动

express 是 Node.js 上最流行的 Web 开发框架,正如他的名字一样,使用它我们可以快速的开发一个 Web 应用。

$ npm install -g express-generator

新建一个工程

$ express -e app
$ cd app && npm install

启动项目

$ npm start

 

模拟后端json数据

npm install -g json-server

Create a db.json file with some data

{
  "posts": [
    { "id": 1, "title": "json-server", "author": "typicode" }
  ],
  "comments": [
    { "id": 1, "body": "some comment", "postId": 1 }
  ],
  "profile": { "name": "typicode" }
}

Start JSON Server

json-server --watch db.json

Now if you go to http://localhost:3000/posts/1, you'll get

{ "id": 1, "title": "json-server", "author": "typicode" }

 

posted @ 2020-09-09 15:04  nalasu  阅读(1133)  评论(0)    收藏  举报