I develop a Kibana plugin where I try to use axios HTTP client. Now my code fails with
1. error: "Bad Request"
2. message: "Request must contain a kbn-xsrf header."
3. statusCode: 400
Where can I get the correct kbn-xsrf
value?
The code which fails:
import axios from 'axios';
export default class {
constructor() {
this.http = axios.create({
headers: { 'Content-Type': 'application/json' }
});
}
statField(index, field, filters = []) {
const query = {
query: {
bool: {
must: [
...filters.map(filter => ({
match: {
[filter.field]: filter.value
}
}))
]
}
},
aggs: {
stat_agg: {
stats: { field }
}
},
size: 0
};
return this.http.post(`../elasticsearch/${index}/_search`, query)
...