See Why the Booking Page Fails

Your walks API now reads its settings from .env and checks them before it answers a single request. It runs on port 3000, the port Priya’s booking page expects, so it’s time for the co-op to use the page. Until now, you’ve tested the API with curl, but every neighbor who wants a walk for their dog will book it on Priya’s page.

In this lesson, you’ll open the booking page, watch it fail, and work out exactly where the failure happens. You’ll read the browser’s error message, compare it with what your server logged, and be able to explain which part of the exchange stopped the page. Start by opening the page the way a neighbor would.

Open the Booking Page

The page and the API are two separate programs, so you need both running. In one terminal, start the API as you did in the previous lessons:

Language: Shell
$ npm start

Leave it running. Its terminal is where your timing middleware prints one line per request, with the request’s ID, method, path, status, and duration. Then open a second terminal in the same project folder and start the small server for Priya’s page with the project’s page script:

Language: Shell
$ npm run page

> [email protected] page
> node page-server.ts

Booking page on http://localhost:5173

Open http://localhost:5173 in Chrome. Then press Ctrl+Shift+J, or Cmd+Option+J on macOS, to open Chrome’s developer tools on the Console tab. Reload the page so the Console catches everything from the start.

When the page loads, its script calls fetch() to get http://localhost:3000/walks and list the week’s walks. Instead of the list, the page shows an error message, and the Console has this in red:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.