Articles
Latest
More
Newsletter Sponsorship Discord About
Sign up for our Newsletter
The video for this lesson is currently being updated, please read the transcript instead.
Full-Stack Vue + Node > Lesson 22

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...

Articles
  • Latest
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

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

  • RSS
  • |
  • Atom