【发布时间】:2018-11-10 19:47:19
【问题描述】:
我的 Node.js 应用程序中有一个弹性查询,如下所示。我正在使用弹性搜索版本 6.2.2。但是当我从邮递员执行 API 时,它显示以下错误:
Unhandled rejection Error: Content-Type header [] is not supported
exports.radix = function (req, res) {
var elasticsearch = require('elasticsearch'),
client = new elasticsearch.Client({
host: 'localhost:9200'
});
client.search({
index: 'xpertradix',
type: 'search',
size: 20,
body: {
query: {
match: {
name: req.param('term')
}
}
}
}).then(function (resp) {
var data = helper.prepareRadix(resp.hits.hits);
res.json(data);
});
};
我已经苦苦挣扎了 2 天来解决这个问题。有人可以帮我解决这个问题吗?
【问题讨论】:
-
在编程笔记中,如果您使用的是
then,请务必同时添加.catch,这样您就可以实际调试/检查您的错误案例。
标签: node.js express elasticsearch mongoose mean-stack