callWithRequest not a function

Hi,

I attempt to write a Kibana plugin, which is a custom application. Before implementing my needs, I'm studying the source code of an existing plugin "elasticsearch_status". But I run into an error when I tried to access that app in my local dev environment.

Please look at below error message:

server error [08:34:10.224] TypeError: Uncaught error: call is not a function at handler (/Users/caoping/Code/Workspace/elasticsearch_status/server/routes.js:31:7)
at Object.internals.handler (/Users/caoping/Code/Workspace/kibana/node_modules/hapi/lib/handler.js:96:36)

This is code snippet of that routes.js:

let call = server.plugins.elasticsearch.callWithRequest;
server.route({
path: '/api/elasticsearch_status/indices',
method: 'GET',
handler(req, reply) {
call(req, 'cluster.state').then(function (response) {
// Return just the names of all indices to the client.
reply(
Object.keys(response.metadata.indices)
);
});
}
});

I didn't change the source code, just tried to run it in my laptop. Any ideas about that error? Thanks a lot!

BTW, I put the source code of that plugin under the same folder that kibana source code resides, then I run "npm start" under elasticsearch_status, instead of kibana.

-Workspace
   -elasticsearch_status
   -kibana

Hope this information helpful.

Which version of kibana are you using? In 5.2+ the API has changed slightly, docs here. It would look something like const call = server.plugins.elasticsearch.getCluster('data').callWithRequest

Thanks so much for your reply. I'm using the source code from master in github, it's 6.0.0-Alpha. I'll try your solution later. Hope it work. Thank you again:grinning:

Thank you. That plugin works correctly now.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.