@@ -1,6 +1,7 @@
<template>
<form v-if="active === 'register'" v-on:submit="register" id="register-form">
<h3>Registration</h3>
<div>{{errorMessage}}</div>
<div>
<label for='sender_name'>Name</label>
<input id='register-name' required type='name' name='sender_name' placeholder=''
@@ -44,7 +45,7 @@
<p>A password reset link has been sent.</p>
</div>
<div v-if="active === 'error'">
<img class="medium-icon" src="../../images/warning.svg" alt="">
<img class="medium-icon" src="../../images/warning-colored .svg" alt="">
<h3>An Error Occured.</h3>
<p>{{`${error}: ${errorMessage}`}}</p>
</div>
@@ -57,6 +58,7 @@
fetch("/register", {
method: 'POST',
headers: {'Content-Type': 'application/json',
'Accept': 'application/json',
'X-XSRF-TOKEN': this.token},
body: JSON.stringify({"name": document.getElementById("register-name").value,
"email": document.getElementById("register-email").value,
@@ -65,13 +67,18 @@
.then(response => {
//Give completed or error
if (response.ok) {
this.active = 'completed'
this.active = 'register- completed'
} else {
this.error = response.status
this.errorMessage = response.statusText
this.active = 'error'
if (response.status === 422) {
this.errorMessage = 'That email is already registered.'
this.active = 'register'
} else {
this.error = response.status
this.errorMessage = response.statusText
this.active = 'error'
}
}
console.log(response)
/* console.log(response.json( )) */
});
event.preventDefault();
}