Join Daniel Khan for an in-depth discussion in this video Storing data, part of Building a Website with Node.js and Express.js.
- [Instructor] All that is left now is writing new feedback…to the feedback JSON file.…And for that, let's extend the feedback service class.…So I open services, feedback services, and enter.…I will now first now have to promisify…the write file function of fs.…So I copy the read file line from line four…and replace read file with write file.…
So this will again wrap my write file function…to return a promise, instead expecting a callback.…Now let's add a new function async add entry,…which should then do the actual writing…and this takes this arguments…a name, a title, and a message.…
Next let's load the data,…so I add const data equals await this get data.…And what we want to do now…is we want to append the new feedback to data.…So for that I add data.unshift and I pass in,…in shortcut form, name, title, message.…
Again, this would be the same as,…for instance, saying message, column, message.…Next of course, we also have to write this file.…So I return write file.…I return now because I later want…to wait on that and I want to write to this data file.…
- Creating a server with Express and pure Node.js
- Handling errors in Express
- Creating routes
- Using templates
- Working with the Pug template engine
- Implementing the site structure and logic
- Working with conditionals
- Dealing with POST requests
- Sanitizing user inputs and handling form errors
Skill Level Beginner
Building RESTful Web APIs with Node.js and Expresswith Emmanuel Henri1h 40m Intermediate
What you should know1m 40s
1. Getting Started
2. Express Basics
3. Getting Started with Our Project
4. Getting Started with Templates
5. Implementing the Site Structure and Logic
6. Handling Form Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.