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

Unable to get http error response code: 4XX #3693

Closed
Jun711 opened this issue Jul 19, 2019 · 8 comments
Closed

Unable to get http error response code: 4XX #3693

Jun711 opened this issue Jul 19, 2019 · 8 comments
Labels
API Related to REST API issues pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days.

Comments

@Jun711
Copy link

Jun711 commented Jul 19, 2019

Describe the bug
When Api fails with network error, for example 413, the error object doesn't contain error response code. Error is caught but not enough information such as error response code is provided by error object.

To Reproduce
When I uploaded with payload over lambda size limit, I expected to get 413 error code but I couldn't retrieve 413 from the error code.

public put() {
  const apiName = 'myApi';
  const init = {
    headers: {
      'Content-Type': 'application/json'
    },
    body: {
      data: 123  
    },
    response: true
  };

  API.put(apiName, '/get', config)
  .then(res => {
    return res;
  }
  .catch(error => {
    console.error('error: ', error);
    console.error('error.response: ', error.response); // undefined
    console.error('error.name: ', error.name); // Error
    console.error('error.message: ', error.message); // Network Error
  }
}

Expected behavior
Expected to be able to retrieve error response code

Screenshots
aws-amplify-not-showing-error-code

Desktop (please complete the following information):

  • OS: OSX 10.13.6
  • Browser: Chrome 75
  • Version: 75.0.3770.142 (Official Build) (64-bit)

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
It could be just an issue with Axios
axios/axios#1427

Sample code
Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.

Let me know if I use Amplify API incorrectly or you need more information. Thank you.

@haverchuck haverchuck added the API Related to REST API issues label Jul 22, 2019
@stale
Copy link

stale bot commented Aug 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Aug 21, 2019
@Jun711
Copy link
Author

Jun711 commented Aug 21, 2019

bump

@stale stale bot removed the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Aug 21, 2019
@stale
Copy link

stale bot commented Sep 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Sep 20, 2019
@Jun711
Copy link
Author

Jun711 commented Sep 26, 2019

bump

@stale stale bot removed the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Sep 26, 2019
@stale
Copy link

stale bot commented Oct 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Oct 26, 2019
@stale
Copy link

stale bot commented Nov 2, 2019

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Nov 2, 2019
@Aelaiig
Copy link

Aelaiig commented Jan 28, 2020

Did you resolve your issue ?

Unless you have cors problem, I think you have to catch your error in your lambda and send it with headers. You did use amplify API correctly.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Related to REST API issues pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants