Step 2
Create a folder model
inside younote-api
. Create the file Note.js
inside the model
folder, with the following content:
class Note {
constructor(content, author) {
this.content = content;
this.author = author;
}
}
module.exports = Note;
You can now go to index.js
and import Note
to make a sample object:
const Note = require("./model/Note.js");
const note = new Note("Sample Note", "Ali");
console.log(note);
Rerun the Express app and make sure the sample note is printed to the terminal.
Expected output
Note { content: 'Sample Note', author: 'Ali' }