Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api swallows http error?? #79

Closed
robmcguinness opened this issue Feb 6, 2019 · 2 comments
Closed

api swallows http error?? #79

robmcguinness opened this issue Feb 6, 2019 · 2 comments
Assignees

Comments

@robmcguinness
Copy link
Contributor

it seems we are always resolving successfully when making http request. if so, code should be modified to throw error so that try/catch works when async/await. This would be breaking change.

https://github.com/Availity/sdk-js/blob/master/packages/api-core/src/api.js#L179

request(config, afterResponse) {
  if (config.polling) {
    config.attempt = config.attempt || 0;
    config.attempt += 1;
  }

  return this.http(config)
    .then(response => this.onResponse(response, afterResponse))
    .catch(error => {
      const response = this.getError(error);
      // throw here ??? <<<===
      return afterResponse ? afterResponse(response) : response;
    });
}
@christieb7007 christieb7007 self-assigned this Feb 6, 2019
@TheSharpieOne
Copy link
Collaborator

Also, this.getError doesn't seem to do anything useful.

getError(error) {
let response;
if (error.response) {
response = { error };
}
return response;
}

if error.response exists, it will return it... else it will return undefined (and in a very awkward way)

@robmcguinness
Copy link
Contributor Author

#80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants