封装http请求
1.npm init -y
2.npm i
3.原生写法
4.新建文件hoa.js
5.新建index.js
6.执行node index.js 输出结果
引入ctx
1.结构
2.新建request.js
3.新建response.js
4.新建context.js
修改inde.js
修改Hoa.js
6.执行node index.js 输出结果
引入中间件
https://www.cnblogs.com/cckui/p/10991062.html
1.结构
- 两次use如何组合
2.同步操作一
3.同步操作二
4.同步操作三
5.异步操作
6.输出结果
7.修改index.js
8.修改hoa.js
9.执行node index.js 输出结果
使用策略模式弄个路由中间件
1.新建router.js
2.修改index.js
3.执行node index.js 输出结果