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

refactor: employ useAsync composable to reduce repeated patterns in A… #79

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uier
Copy link
Member

@uier uier commented Mar 10, 2023

…PI calls

close #32

@cloudflare-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 34bdc74
Status: ✅  Deploy successful!
Preview URL: https://a2be1e55.nfe.pages.dev
Branch Preview URL: https://refactor-use-async.nfe.pages.dev

View logs

@uier
Copy link
Member Author

uier commented Mar 10, 2023

@Bogay @laporchen Please take a look first before I replace all the similar patterns into new style.

Comment on lines +11 to +16
if (!error.value) return null;
else if (axios.isAxiosError(error.value) && error.value.response?.data?.message) {
return error.value.response.data.message;
} else {
return "Unknown error occurred :(";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use early return to eliminate some nested code.

Suggested change
if (!error.value) return null;
else if (axios.isAxiosError(error.value) && error.value.response?.data?.message) {
return error.value.response.data.message;
} else {
return "Unknown error occurred :(";
}
if (!error.value) return null;
if (axios.isAxiosError(error.value) && error.value.response?.data?.message) {
return error.value.response.data.message;
}
return "Unknown error occurred :(";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, will fix this.

Copy link
Contributor

@laporchen laporchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Successfully merging this pull request may close these issues.

Repeated pattern in components interacting with models
3 participants