Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix(default-theme): show errors from API in right format (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored May 20, 2021
1 parent ac8ead9 commit 0fa8898
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/composables/src/hooks/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export const useUser = (rootContext: ApplicationVueContext): IUseUser => {
return true;
} catch (e) {
const err: ClientApiError = e;
// temporary workaround - get rid of such hacks in the future
// TODO: https://github.com/vuestorefront/shopware-pwa/issues/1498
errors.register = [err.message as string];
broadcast(INTERCEPTOR_KEYS.ERROR, {
methodName: `[${contextName}][register]`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,16 @@ export default {
const { login, register, loading, error: userError, errors } = useUser(root)
const { getCountries, error: countriesError } = useCountries(root)
const { getSalutations, error: salutationsError } = useSalutations(root)
const formErrors = computed(() => errors.register)
// temporary fix for accessing the errors in right format
// TODO: https://github.com/vuestorefront/shopware-pwa/issues/1498
const formErrors = computed(() =>
getMessagesFromErrorsArray(
(Array.isArray(errors.register) &&
errors.register.length &&
errors.register[0]) ||
([] as any)
)
)
const state = reactive({
firstName: "",
Expand Down

1 comment on commit 0fa8898

@vercel
Copy link

@vercel vercel bot commented on 0fa8898 May 20, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.