vue-realworld-example-app icon indicating copy to clipboard operation
vue-realworld-example-app copied to clipboard

Transform Check Auth call to async/await

Open igeligel opened this issue 6 years ago • 1 comments

Issue Summary:

In the auth.module.js here you have got some code like:

[CHECK_AUTH](context) {
  if (JwtService.getToken()) {
    ApiService.setHeader();
    ApiService.get("user")
      .then(({ data }) => {
        context.commit(SET_AUTH, data.user);
      })
      .catch(({ response }) => {
        context.commit(SET_ERROR, response.data.errors);
      });
  } else {
    context.commit(PURGE_AUTH);
  }
}

Those promise calls could be simplified with async and await calls.

Resources:

Acceptance Criteria:

  • A test is introduced, this is perfect work for TDD
  • There is no .then(... or .catch(... block or any promise like structure

The main issue can be found here #5

igeligel avatar Oct 12 '18 19:10 igeligel

PR #269

ydegtyar avatar Oct 25 '19 17:10 ydegtyar