Elasticsearch-js: TypeError:cannot read property 'requst' of undfined

Created on 27 Jul 2017  路  4Comments  路  Source: elastic/elasticsearch-js

Hi there,
I'm using your package, to add a log into kibana, and I get this error:

TypeError cannot read property 'request' of undefined
at exec ...node_modules/elasticsearch/src/lib/client_action.js : 364:19
at action ... node_modules/elasticsearch/src/lib/client_action.js : 61:16
and the rest of the stack is mine.

I use the index function within the client object.

elasticsearch:13.2
node: 8.1.2

hope to solve it. thanks!

stale

Most helpful comment

the only request property in the client_action is this.request, which means the function that you're accessing has probably lost this context. Are you calling the method like client.index() or have you assigned index to a separate value and called it directly, like

var index = client.index;
index()

If it's the later then you need to bind the this context to the index function with something like the .bind() method:

var index = client.index.bind(client);
index()

All 4 comments

i have the exact same issue

Same here

the only request property in the client_action is this.request, which means the function that you're accessing has probably lost this context. Are you calling the method like client.index() or have you assigned index to a separate value and called it directly, like

var index = client.index;
index()

If it's the later then you need to bind the this context to the index function with something like the .bind() method:

var index = client.index.bind(client);
index()

We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours.
It will be closed if no further activity occurs, please write a comment if you would like to keep this going.

Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaustavghosh06 picture kaustavghosh06  路  5Comments

loretoparisi picture loretoparisi  路  3Comments

aimyth picture aimyth  路  3Comments

lizpark picture lizpark  路  3Comments

lamontadams picture lamontadams  路  4Comments