Open weikee94 opened 4 years ago
async await demo
// async await method
readFileData = async () => {
// 同步写法
const aData = await getFileContentPromise("a.json");
console.log("a data: ", aData);
const bData = await getFileContentPromise(aData.next);
console.log("b data: ", bData);
const cData = await getFileContentPromise(bData.next);
console.log("c data: ", cData);
};
readFileData();
koa2 install
koa2 router 配置
/api/blog/list
const router = require("koa-router")();
router.prefix("/api/blog");
router.get("/list", async function (ctx, next) {
const query = ctx.query;
ctx.body = {
errno: 0,
query,
data: ["获取博客列表"],
};
});
module.exports = router;
Content