Using await in promise chain

Viewed 18402

I just upgraded to node 8 and want to start working with async/await. I came across an error which took me a while to solve and I was actually just wondering if there's a more graceful way. I didn't want refactor the whole function at this point in time because of all the secondary refactors it would lead to.

async doSomething(stuff) {
...

  return functionThatReturnsPromise()
    .then((a) => ...)
    .then((b) => ...)
    .then((c) => {
      const user = await someService.createUser(stuff, c);
      user.finishSetup();
    });
};

is there a way to be able to use await in the promise chain without having to refactor everything above to be async as well?

1 Answers
Related