标签:tostring Koa sync console listen 还原 eth ring new
cookies本身在koa中即可直接设置和使用,不需要在安装中间件
//cookies的使用 const koa = require(‘koa‘); var router = require(‘koa-router‘)(); var views = require(‘koa-views‘); const static = require(‘koa-static‘); const bodyParser =require(‘koa-bodyparser‘); var app = new koa(); app.use(views(‘views‘,{ map:{ html:‘ejs‘ } })); app.use(bodyParser()); app.use(static(‘./www‘)); router(‘/‘,async(ctx)=>{ ctx.cookies.set(‘id‘,‘123‘,{maxAge:1000});//设置cookie值,第一个参数为name,第二个为values,第三个为可选选项 id = ctx.cookies.get(‘id‘); }); console.log(new Buffer(‘hello, world!‘).toString(‘base64‘));// 转换成 base64 字符 串:aGVsbG8sIHdvcmxkIQ== console.log(new Buffer(‘aGVsbG8sIHdvcmxkIQ==‘, ‘base64‘).toString());// 还原 base 64 字符串:hello, world! app.use(router.routes()); app.use(router.allowedMethods()); app.listen(80);
标签:tostring Koa sync console listen 还原 eth ring new
原文地址:https://www.cnblogs.com/Liqian-Front-End-Engineer/p/11794558.html