This lesson will rely on the built-in support for async functions found in Express 5 to demonstrate how an API can easily work with data asynchronously. By the end of the lesson our API will have the ability to save its notes to disk as they're added and read them when the server starts up again.
First we'll update our Note model to persist data to the filesystem using the MapStore
class created in a previous lesson. Then we'll access those updated methods on the Note model using the await
keyword in our routes. We'll also briefly discuss the importance of catching errors that come from promises and async functions.
Resources
async/await
read Getting started with async/await.A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.