From the course: Vue.js 2 for Web Designers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Hooking up the form to post an update

Hooking up the form to post an update - Vue.js Tutorial

From the course: Vue.js 2 for Web Designers

Start my 1-month free trial

Hooking up the form to post an update

- [Instructor] In this video we're going to wire up the post form so we're actually sending data to the database via the API. To do this we're going to need a new method that we'll fire when the form is submitted. We'll collect all the data that needs to be posted and then post it. We'll be using the post method for Axios to do this, very similarly to what we did to retrieve the messages originally. So back here in hotel.js, I'll scroll down to my post status form component here and after the template I'm going to add a methods key. And this method, we'll call it postUpdate. This will be a function. I'm passing in an event grounder here. I like to abbreviate this evt, because we're going to fire this when the form submits. So while we're here, I'll hook this up to the submit event on this form using @submit. I'll copy and paste the name of my method. Okay, so what does this method actually need to do? Well first we're going to prevent the default action from taking place, so the page…

Contents