当前位置:网站首页>Koa2 cannot receive the formdata data submitted by the post method (value: {})
Koa2 cannot receive the formdata data submitted by the post method (value: {})
2022-07-21 03:22:00 【cc_ King】
List of articles
terms of settlement
- The first thing to use must be
koa-body
This middleware ; - secondly , Just configure the parameters ;
const Koa = require('koa')
const app = new Koa()
const bodyparser = require('koa-body')
app.use(bodyparser({
enableTypes: ['json', 'form', 'text'],
multipart: true // ***** This is this. ( Do you support multipart-formdate Form for )
}))
- Last It can be used in routing
router.post('/register', function (ctx, next) {
console.log(ctx.request.body); // Here you can get the parameters from the front end
ctx.response.body = "";
})
Small warning ( Be careful )
const bodyparser = require('koa-body')({
// If you configure parameters here once
multipart: true
})
app.use(bodyparser({
// Here is another configuration ,name This configuration will overwrite the above , That is to say, the above configuration does not take effect
enableTypes: ['json', 'form', 'text'],
}))
// At the beginning, I suffered this loss , go to a lot of trouble for nothing
Attach the configuration instruction document
NPM documentation
Chinese translation published by a blogger : Parameters
边栏推荐
猜你喜欢
随机推荐
Flink SQL实现对Kafka的数据处理,写入TiDB
mongoose使用validate验证, 获取自定义验证信息
使用反射的方式将RDD转换为DataFrame
[dish of learning notes dog learning C] array
mysql_账号授权权限回收、账号锁定解锁、账号创建删除
[dish of learning notes, dog learning C] get familiar with common keywords, define constants and macros
数组常用方法
Flink 水位线(Watermark)
mysql_不区分大小写
[dish of learning notes dog learning C] initial level of structure
【学习笔记之菜Dog学C】指针进阶
达梦dem部署
达梦数据库TPCC性能测试
[dish of learning notes dog learning C] initial level of pointer
页面性能:如何系统地优化页面?
【C】 C语言入门
问题 B: 蓝桥杯2020年第十一届省赛真题-回文日期
【学习笔记之菜Dog学C】初识常见关键字、#define定义常量和宏
Parameters and calls of the [learning notes dish dog learning C] function
Flink-时间语义