node如何使用express编写api
所需工具:Mongodb数据库,express,Router,node
1.连接Mongodb数据库:需要安装(mongoose) 不需要抛出。
2.添加字段然后通过mongoose,model()转为数据模型:需要(Schema) 需要抛出此模块。
3.(1)创建端口号 app.listen 无回调函数以及POST请求参数配置 (body-parser)app.use(),然后指定router路由写法。
4.编写您的api,然后通过路由模块名.insertMany()添加到您的数据库。