Step 8
Let's document our HTTP requests as we implement them:
| Read Notes | |
|---|---|
| HTTP Method | GET |
| API Endpoint | /api/notes |
| Request Path Parameter | |
| Request Query Parameter | |
| Request Body | |
| Response Body | JSON array of notes |
| Response Status | 200 |
Add this route to index.js:
app.get("/api/notes", async (req, res) => {
const data = await notes.readAll();
res.json({ data });
});
As you save the code, nodemon reruns the Express application. Open your browser and head over to http://localhost:5000/api/notes. You must receive a JSON array containing our 3 sample notes.
You can also hit this endpoint on Postman to test it.
