node+koa2获取请求参数

1.get方式:

http://localhost:3000/?user=000001&body=0002&age=26

const router = require('koa-router')()

router.get('/',async (ctx, next) => {
console.log('接受到的参数为:'+ctx.request.query.user);
await ctx.render('index', {
title: 'Hello Koa 22222222222222222!'
})
})

2.post方式:

ctx.request.body.user

 3.重定向:

ctx.redirect('http://google.com');

posted @ 2018-03-20 13:30  江山一族  阅读(386)  评论(0编辑  收藏  举报