May 2018
Intermediate to advanced
492 pages
12h 3m
English
The models directory contains two modules: Note.js defines the Note class, and notes-memory.js contains an in-memory data model. Both are easy to convert to ES6 modules.
Change the filenames:
$ cd models$ mv Note.js Note.mjs$ mv notes-memory.js notes-memory.mjs
In Note.mjs, simply make the following change:
export default class Note { ...}
This makes the Note class the default export.
Then, in notes-memory.mjs, make the following change:
import Note from './Note';var notes = [];async function crupdate(key, title, body) { notes[key] = new Note(key, title, body); return notes[key];}export function create(key, title, body) { return crupdate(key, title, body); }export function update(key, title, body) { ...
Read now
Unlock full access