在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:varunpal/koa-cookie开源软件地址:https://github.com/varunpal/koa-cookie开源编程语言:JavaScript 100.0%开源软件介绍:koa-cookieCookie parser middleware for koa. Can also be used with koa-router. Installnpm install koa-cookie --save Exampleimport Koa from 'koa';
import cookie from 'koa-cookie';
const app = Koa();
app.use(cookie());
app.use(async function (ctx, next) {
const cookies = ctx.cookie;
/*
if cookies sent are of the form: 'name=abc; age=20; token = xyz;'
Then ctx.cookie is an object of the form:
{
name: 'abc',
age: '20',
token: 'xyz'
}
*/
}); Example with koa-routervar app = require('koa')();
var cookie = require('koa-cookie');
var router = require('koa-router')();
router.use(cookie.default());
router.get('/', async (context) => {
const cookies = context.cookie;
/*
if cookies sent are of the form: 'name=abc; age=20; token = xyz;'
Then ctx.cookie is an object of the form:
{
name: 'abc',
age: '20',
token: 'xyz'
}
*/
});
app
.use(router.routes())
.use(router.allowedMethods()); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论