node+koa2获取请求参数

1.get方式:koa

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

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

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

2.post方式:google

ctx.request.body.userspa

 3.重定向:router

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

相关文章
相关标签/搜索