Here, we will create the <script> section of the single file component:
- In the client/components folder, create a file named TodoForm.vue and open it.
- Then, we will export a default JavaScript object, with a name property defined as TodoForm, then define the methods property as an empty JavaScript object. Then, create a data property defined as a singleton function returning a JavaScript object. In the data property, create a task property as an empty array:
export default {
name: 'TodoForm',
data: () => ({
task: '',
}),
methods: {},
};
- In the methods property, create a method named save, which will be an asynchronous function. This method will send the task to the API, and if the API receives Ok Status, it will emit a 'new-task' event with the task and clean task property:
async save() {
try {
const { status } = await
this.$axios.$post('http://localhost:5000/&apos...