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');

原文地址:https://www.cnblogs.com/qiyc/p/8608733.html