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