Last active
August 17, 2017 18:40
-
-
Save sahibalejandro/c92d85a6756443f08f18ab0759aac0c4 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<form @submit.prevent="submit"> | |
<input type="email" v-model="user.email"/> | |
</form> | |
</template> | |
<script> | |
import Form from 'form-object'; | |
export default { | |
data() { | |
return { | |
form: new Form(), | |
user: { | |
email: null | |
} | |
} | |
}, | |
methods: { | |
submit() { | |
this.form.submit('POST', '/api/users', this.user) | |
.then(data => { | |
// "data" is whatever you return from your server. | |
}) | |
.catch(error => { | |
// Something went wrong. | |
}); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment