1、让elasticsearch支持跨域

echo "http.cors.enabled: true" >> 向elasticsearch.yaml
echo "http.cors.allow-origin: /.*/" >>向elasticsearch.yaml

2、安装axios、编写js

npm install axios

3、编写js

let api = "http://www.xxx.com:9200/test/_search";
Axios({
  method: 'POST',
  url: api,
  data: {
  	"query": {
  		"bool": {
        	"must": [
                { "match": { "ProjectName": this.listQuery.info } },
                { "match": { "Status": "Error" } }
             ]
         }
     },
     "size": this.listQuery.page_size
        },
}).then(res => {
  console.log(res.data)
})

在这里插入图片描述

Logo

前往低代码交流专区

更多推荐