laravel-request-utils
v2.0.0
Published
Form and Request classes that help working Laravel backend.
Downloads
71
Readme
Laravel Request Utils Package
Installation
npm i laravel-request-utils
Usage
- Configure the request if needed.
// index.js
import { Request } from 'laravel-request-utils';
Request.setConfig({
// Your config goes here.
});
- Create a new Form instance for Vue component.
<template>
<form @submit.prevent="onSubmit">
<input v-model="form.name" />
<button type="submit">Submit</button>
</form>
</template>
<script>
import { Form } from 'laravel-request-utils';
export default {
name: 'MyFormComponent',
data() {
return {
form: new Form({
name: '',
}),
}
},
methods: {
onSubmit() {
const url = '/your/api/endpoint';
this.form.submit(url)
.then((data) => {
// Logic on successful submit.
});
}
}
}
</script>