Skip to content

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

Draft
uier wants to merge 1 commit into
mainfrom
refactor/use-async
Draft

refactor: employ useAsync composable to reduce repeated patterns in A…#79
uier wants to merge 1 commit into
mainfrom
refactor/use-async

Conversation

@uier

@uier uier commented Mar 10, 2023

Copy link
Copy Markdown
Member

…PI calls

close #32

@cloudflare-workers-and-pages

Copy link
Copy Markdown

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

uier commented Mar 10, 2023

Copy link
Copy Markdown
Member Author

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

Comment thread src/pages/admin.vue
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
Copy Markdown
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
Copy Markdown
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.

@laporchen laporchen left a comment

Copy link
Copy Markdown
Contributor

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