simplofy the promise chain

This commit is contained in:
2016-06-06 16:59:13 -07:00
parent 5954ee1d51
commit 78871f97d9

View File

@@ -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);