Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wrap rejected response, to stay in line with Axios API #90

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

Open
notpushkin wants to merge 1 commit into developit:master
base: master
Choose a base branch
Loading
from notpushkin:patch-1

Conversation

@notpushkin
Copy link

@notpushkin notpushkin commented Sep 16, 2022

Axios returns a custom object when request status is not OK (https://github.com/axios/axios/#handling-errors):

axios.get('/user/12345')
 .catch(function (error) {
 if (error.response) {
 console.log(error.response.data);
 console.log(error.response.status);
 console.log(error.response.headers);
 }
 // ...
 })

Redaxios on the other hand throws the response directly, as pointed out in comment #48 (comment).

The easiest fix would be just to wrap the response in an object, but for better compatibility we could add some other fields.

ecchochan, developit, and arifemir reacted with thumbs up emoji
Copy link
Owner

LGTM - I might try to refactor this to reject with an Error that has the .response property attached (I assume that's what Axios is doing). The current .catch(Object) trick likely has to go though.

kouhin and skivis reacted with thumbs up emoji notpushkin and arifemir reacted with rocket emoji

Copy link
Author

@developit Sorry for bothering – any updates on this? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@quicoto quicoto quicoto approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /