在 express 中获取 post 请求参数时会返回 {} 或者 undefined
问题原因: Express默认只支持json
与x-www-form-urlencoded
格式的数据.
解决办法:
在请求中需要设置Content-type
为application/x-www-form-urlencoded
init();
function init() {
var xhr = new XMLHttpRequest();
xhr
在 express 中获取 post 请求参数时会返回 {} 或者 undefined
问题原因: Express默认只支持json
与x-www-form-urlencoded
格式的数据.
解决办法:
在请求中需要设置Content-type
为application/x-www-form-urlencoded
init();
function init() {
var xhr = new XMLHttpRequest();
xhr