【发布时间】:2018-07-25 02:58:12
【问题描述】:
在我的 nodeJS 应用程序中,我使用以下代码行来获取 req.body
app.use(bodyParser.urlencoded({
extended: false
}));
这工作正常,但是对我的应用程序的一个请求会引发以下错误:
UnsupportedMediaTypeError: unsupported charset "ISO-8859-1"
at urlencodedParser (/var/www/payment/node_modules/body-parser/lib/types/urlencoded.js:108:12)
at Layer.handle [as handle_request] (/var/www/payment/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/var/www/payment/node_modules/express/lib/router/index.js:317:13)
at /var/www/payment/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/var/www/payment/node_modules/express/lib/router/index.js:335:12)
at next (/var/www/payment/node_modules/express/lib/router/index.js:275:10)
at jsonParser (/var/www/payment/node_modules/body-parser/lib/types/json.js:118:7)
at Layer.handle [as handle_request] (/var/www/payment/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/var/www/payment/node_modules/express/lib/router/index.js:317:13)
at /var/www/payment/node_modules/express/lib/router/index.js:284:7
如果我删除前一行,那么它适用于该请求,但在所有其他请求中,我无法检索数据。有没有办法解决这个问题?
【问题讨论】:
标签: node.js express body-parser