simplofy the promise chain
This commit is contained in:
@@ -49,8 +49,7 @@ export default class Job extends events.EventEmitter {
|
||||
if (options.headers) indexParams.headers = options.headers;
|
||||
|
||||
this.ready = createIndex(this.client, this.index, this.doctype)
|
||||
.then(() => {
|
||||
return this.client.index(indexParams)
|
||||
.then(() => this.client.index(indexParams))
|
||||
.then((doc) => {
|
||||
this.document = {
|
||||
id: doc._id,
|
||||
@@ -59,7 +58,6 @@ export default class Job extends events.EventEmitter {
|
||||
};
|
||||
this.debug(`Job created in index ${this.index}`);
|
||||
this.emit('created', this.document);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
this.debug('Job creation failed', err);
|
||||
|
||||
Reference in New Issue
Block a user