Skip to content

Instantly share code, notes, and snippets.

@sahibalejandro
Last active August 17, 2017 18:40
Show Gist options
  • Save sahibalejandro/c92d85a6756443f08f18ab0759aac0c4 to your computer and use it in GitHub Desktop.
Save sahibalejandro/c92d85a6756443f08f18ab0759aac0c4 to your computer and use it in GitHub Desktop.
<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