# callWithRequest not a function

**URL:** <https://discuss.elastic.co/t/callwithrequest-not-a-function/77626>\
**Category:** Kibana\
**Created:** [March 7, 2017, 9:48am UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626 "2017-03-07T09:48:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![caoping](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@caoping](https://discuss.elastic.co/u/caoping)\
**Post date:** [March 7, 2017, 9:48am UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626/1 "2017-03-07T09:48:30Z")

</div>

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](https://github.com/timroes/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

```

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [March 7, 2017, 6:59pm UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626/2 "2017-03-07T18:59:03Z")

</div>

Which version of kibana are you using? In 5.2+ the API has changed slightly, docs [here](https://www.elastic.co/guide/en/kibana/5.x/development-elasticsearch.html). It would look something like `const call = server.plugins.elasticsearch.getCluster('data').callWithRequest`

---

<div class="post-metadata">

**Author:** ![caoping](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@caoping](https://discuss.elastic.co/u/caoping)\
**Post date:** [March 8, 2017, 1:10am UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626/3 "2017-03-08T01:10:43Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![caoping](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@caoping](https://discuss.elastic.co/u/caoping)\
**Post date:** [March 8, 2017, 1:18am UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626/4 "2017-03-08T01:18:05Z")

</div>

Thank you. That plugin works correctly now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 5, 2017, 1:18am UTC](https://discuss.elastic.co/t/callwithrequest-not-a-function/77626/5 "2017-04-05T01:18:18Z")

</div>

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