Step 9

Here is another GET request.

Read Notes (filter by author)
HTTP MethodGET
API Endpoint/api/notes
Request Path Parameter
Request Query Parameterquery
Request Body
Response BodyJSON array of notes
Response Status200

For this one, we expect a client to use the same endpoint as before but optionally provide a search query parameter. We can update the route we already have (/api/notes) to account for this scenario:

app.get("/api/notes", async (req, res) => {
  const { query } = req.query;
  const data = await notes.readAll(query);
  res.json({ data });
});

Save the code, and then test this endpoint in Postman.