Step 7

We should populate our server with some data to test it. We can generate fake data! Let's install the faker package:

npm i faker@5.5.3

Next, open the index.js file and add the following import statements:

const faker = require("faker");
const NoteDao = require("./data/NoteDao");

Follow it by this script to create sample notes:

const NUM_SAMPLES = 3;
const notes = new NoteDao();
for (let i = 0; i < NUM_SAMPLES; i++) {
  notes.create({
    title: faker.lorem.sentence(),
    text: faker.lorem.paragraph(),
  });
}

Save and commit the changes.

Recall the following HTTP verbs (operations):

  • POST: to create a resource
  • PUT: to update it
  • GET: to read it
  • DELETE: to delete it

We will start with HTTP GET requests.