Created
June 10, 2018 01:23
-
-
Save jordanhudgens/a24b6ad62dc8d24b42b09e7e7a6ddda0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<h2>Register</h2> | |
<form @submit.prevent="submitRegistration"> | |
<div> | |
<input type="text" v-model="email"> | |
</div> | |
<div> | |
<input type="password" v-model="password"> | |
</div> | |
<div> | |
<input type="password" v-model="password_confirmation"> | |
</div> | |
<button type="submit">Register</button> | |
</form> | |
</div> | |
</template> | |
<script> | |
import axios from 'axios'; | |
export default { | |
name: 'Registration', | |
data() { | |
return { | |
email: null, | |
password: null, | |
password_confirmation: null | |
} | |
}, | |
methods: { | |
submitRegistration() { | |
axios | |
.post("your-url-registration-endpoint-url", | |
{ | |
user: { | |
email: this.email, | |
password: this.password, | |
password_confirmation: this.password_confirmation | |
} | |
}) | |
.then(response => { | |
console.log('created successfully', response.data); | |
return response.data; | |
}) | |
.catch(error => { | |
console.log(error); | |
}) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment