Courses
Vue Foundations Vue Fullstack Vue Enterprise
Articles
Latest Topics
More
Newsletter Sponsorship Discord About
The video for this lesson is currently being updated, please read the transcript instead.
Enterprise Vue > Lesson 23

Writing to the database

Now that we're receiving the request body as JSON, we can put this data in our database.

Let's require our Item model at the top of the controller. Then, in the create method, we'll create a new Item, using the request body.

Let's now add a try/catch block, too. In the try, we'll await model.save();. Since we're using async/await, we'll need to make this controller method an async method, too.

server/controllers/items.js


Back to course page

Click to load comments...

Courses
  • Vue Foundations
  • Vue Fullstack
  • Vue Enterprise
Articles
  • Latest
  • Topics
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

Vue.js Developers © 2021. View our privacy policy .

  • RSS
  • |
  • Atom