From 78871f97d90a1008f6686bc51cf952c92b1c6a0e Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 6 Jun 2016 16:59:13 -0700 Subject: [PATCH] simplofy the promise chain --- src/job.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/job.js b/src/job.js index 7e8ee0f..d331b42 100644 --- a/src/job.js +++ b/src/job.js @@ -49,17 +49,15 @@ 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((doc) => { - this.document = { - id: doc._id, - type: doc._type, - version: doc._version, - }; - this.debug(`Job created in index ${this.index}`); - this.emit('created', this.document); - }); + .then(() => this.client.index(indexParams)) + .then((doc) => { + this.document = { + id: doc._id, + type: doc._type, + version: doc._version, + }; + this.debug(`Job created in index ${this.index}`); + this.emit('created', this.document); }) .catch((err) => { this.debug('Job creation failed', err);