Node.js

问: nodeJS
答:使用express (E科斯破尔斯) 写过查询数据接口 以及按id查询接口 select (斯列特)
查询所有 select * from 表名
按id查询 select * from 表名 where id=??

使用方法:
1. 加载Express模块
2. 加载MySQL模块
3. 加载bodyParser模块
4. 创建MySQL连接池
5. 创建服务器对象 提供端口号
// 加载CORS模块
const cors = require('cors');
// 使用CORS中间件
server.use(cors({
origin: ['http://localhost:8080', 'http://127.0.0.1:8080']
}));
下面写端口

posted on 2022-02-23 13:44  未茉  阅读(31)  评论(0编辑  收藏  举报

导航