Closed sbressey closed 5 years ago
Hi @sbressey,
I wasn't able to reproduce your issue with the following minimalist plugin. Can you provide me the code that trigger the bug?
class CorePlugin {
constructor () {
this.context = null;
this.config = {};
this.hooks = {};
this.pipes = {};
this.controllers = {
'myNewController': {
'myNewAction': 'test'
}
};
this.routes = [
{verb: 'get', url: '/test', controller: 'myNewController', action: 'myNewAction'},
];
}
init (customConfig, context) {
this.config = Object.assign(this.config, customConfig);
this.context = context;
this.kuzzle = this.context.accessors.sdk;
}
async test () {
const exists = await this.kuzzle.index.exists('nyc-open-data');
console.log(exists);
return `Index exists? : ${exists}`;
}
}
module.exports = CorePlugin;
curl localhost:7512/_plugin/kuzzle-core-plugin-boilerplate/test
Found the issue : my custom method call using index.create missed an await before. index.create is working as expected.
When using the index.exists method with JS6 SDK, I always get an empty object instead of getting a boolean response.
Expected Behavior
method should return boolean and not an object
Steps to Reproduce
1.Create a kuzzle plugin 2.get the sdk in init method :
this.kuzzle = this.context.accessors.sdk;
3.Call the index.exists mehod :const exists = await this.kuzzle.index.exists(indexName)
4.variable exists is an empty objectContext (Environment)
Kuzzle : kuzzleio/plugin-dev:1.6.4 ES : 5.6.10