服务端URL :http://localhost:3000/
- code:200 表示成功
- code:201 表示失败
- code:500 表示服务端错误
GET/registUser
await newUser.save().then(() => {
ctx.body = {
code: 200,
message: '注册成功'
};
}).catch(err => {
ctx.body = {
code: 500,
message: err
};
});
POST/loginUser
ctx.body = {
code: 200,
message: '登录成功',
userInfo: result
}
ctx.body = {
code: 201,
message: '登录失败'
};
- 获取商品数据 : GET/insertProductInfo
- 获取商品类型 : GET/getProductsByType
- 获取商品详情 : GET/getDetail
- 添加 : POST/addCart
- 获取 : GET/getCart
- npm install koa --save
- 是node和MongoDB数据通讯的数据建模库
- 安装: npm install mongoose --save
- 安装glob : npm install glob --save
- npm install koa-router --save
- 解析Post参数
- npm install koa-bodyparser --save
- npm install bcrypt --save
- 解决跨域:npm install koa2-cors --save