Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
front_recipes
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e64f1e1b
authored
Aug 31, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
perf(Register): muestro en el formulario los errores personalizados
parent
45c3766b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
src/views/Register.vue
src/views/Register.vue
View file @
e64f1e1b
...
...
@@ -3,6 +3,12 @@
<div
class=
"form-signin w-100 p-5 shadow rounded bg-white form-card"
>
<h2
class=
"mb-4 text-center"
>
Registrarse
</h2>
<div
v-if=
"errorMsgs.length > 0"
class=
"alert alert-danger"
role=
"alert"
>
<ul>
<li
v-for=
"msg in errorMsgs"
:key=
"msg"
>
{{
msg
}}
</li>
</ul>
</div>
<form
@
submit
.
prevent=
"handleRegister"
>
<div
class=
"form-floating mb-4"
>
<input
...
...
@@ -79,10 +85,10 @@ const name = ref('');
const
surname
=
ref
(
''
);
const
email
=
ref
(
''
);
const
password
=
ref
(
''
);
const
errorMsg
=
ref
(
''
);
const
errorMsg
s
=
ref
([]
);
async
function
handleRegister
()
{
errorMsg
.
value
=
''
;
errorMsg
s
.
value
=
[]
;
try
{
await
authStore
.
register
({
name
:
name
.
value
,
...
...
@@ -92,7 +98,13 @@ async function handleRegister() {
});
router
.
push
(
'/recipes'
);
}
catch
(
error
)
{
errorMsg
.
value
=
error
.
message
;
// Verifica que la respuesta de error existe y tiene el mensaje
if
(
error
.
response
&&
error
.
response
.
data
&&
error
.
response
.
data
.
errorMsg
)
{
// Divide la cadena de mensajes y la asigna al array
errorMsgs
.
value
=
error
.
response
.
data
.
errorMsg
.
split
(
'; '
);
}
else
{
errorMsgs
.
value
=
[
'Ocurrió un error inesperado. Inténtalo de nuevo.'
];
}
}
}
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment