Mrs. Okafor’s phone rings with the same three questions every week: which plots are free, how big plot 7 is, and how to join the waiting list. The finished plot board answers those questions over HTTP, and before you write a line of it, you’ll call it the way you’ve called every API so far.
You already know this side of the exchange well. You’ve sent requests with curl -i and fetch() and read the status line, headers, and body that came back. In this lesson, you’ll start the finished board on your own computer, call it from the terminal and from a script, and then sort out which parts of each exchange you chose and which parts the server decided. Start by getting the board running.
Start the Finished Plot Board
Before you can call a server, something has to be listening for your requests. The finished board is a Node.js program, and you get it from the course’s code download, a ZIP file. You’ll use the finished board in this lesson, and from the next lesson on, you’ll build your own board in the starting project from the same download.
You’ll find the download link on the course’s page and in its first lesson, Your First Server With node:http (Overview). Download the ZIP file from there and extract it. The board needs no npm packages to run, so you can start it without installing anything.
Open a terminal in the extracted 01-call-server folder, the one that contains package.json and server.ts, and start the board with npm start:
$ npm start
> [email protected] start
> node server.ts
Listening on http://localhost:3000
Notice that the prompt doesn’t come back after that last line. Every script you’ve run so far did its work and exited, but this program keeps running. Waiting for requests and answering each one as it arrives is what makes it a server.
The address in the message tells you where to find it. localhost is the name your computer uses for itself, and 3000 is the port the board listens on. For now, the board is only a few lines of output in a terminal on your own machine, a long way from a real website. However, the requests you send it are real HTTP.
Leave this terminal alone while the board runs, and open a second terminal for everything that follows.
Ask a Question With curl -i
Mrs. Okafor’s most common call is about a single plot, so ask the board about plot 7. In the second terminal, run curl -i with the plot’s address. The -i option shows the status line and headers as well as the body:
$ curl -i http://localhost:3000/plots/7
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Thu, 26 Nov 2026 23:23:31 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 47
{"number":7,"size":500,"holder":"Daniel Price"}
This response has the same shape as those you’ve read from public APIs: a status line, headers, a blank line, and then the body. The body is JSON, and the Content-Type header says so, along with the text encoding, UTF-8. Content-Length gives the body’s size in bytes. Plot 7 is 500 square feet, and Daniel Price has it. Your Date line will show the moment you ran the command.
Before you send another request, glance at the first terminal. Under the listening message, the board has printed a new line, GET /plots/7. The board logs the method and URL of every request it receives, and you’ll see why that log is useful in Follow a Request Through the Server.
Hollybank has only twenty-four plots, so try asking for plot 99. Before you run the command, decide which status code you expect the board to send back:
$ curl -i http://localhost:3000/plots/99
$ curl -i http://localhost:3000/plots/99
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8
Date: Thu, 26 Nov 2026 23:23:31 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 82
{"error":{"code":"plot_not_found","message":"There's no plot 99.","details":null}}
The board answers with 404 Not Found and a JSON body that explains the problem. Nothing about your request was different from the first one except the number. The program on the other end looked at the path, found no plot 99 in its data, and chose to send a 404.
You can ask Mrs. Okafor’s other big question, too. A query string filters the list down to the plots nobody has:
$ curl -i "http://localhost:3000/plots?vacant=true"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Thu, 26 Nov 2026 23:23:31 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 117
[{"number":4,"size":250,"holder":null},{"number":13,"size":250,"holder":null},{"number":20,"size":500,"holder":null}]
Plots 4, 13, and 20 are free. The quotes around the address keep your shell from treating the ? as a special character.
Call It From a Script With fetch()
A terminal is fine for one question, but a program that uses the board, such as a script that looks up a plot’s size and holder whenever someone phones Mrs. Okafor about the plot, would call the board from code.
Save this script as call-board.ts in the board’s folder, next to server.ts. That folder’s package.json sets "type": "module", so Node.js runs the file as an ES module. That’s what lets you use await at the top level of the script:
call-board.ts
const url = "http://localhost:3000/plots/7";
const response = await fetch(url);
console.log(response.status, response.statusText);
console.log(response.headers.get("content-type"));
const plot: unknown = await response.json();
console.log(plot);
The script uses the same method and URL as your first curl command, but sends different request headers. It types the parsed body as unknown, as you should with any data from outside your program until you check it. Run it with Node.js from the board’s folder in your second terminal, while the board is still running:
$ node call-board.ts
200 OK
application/json; charset=utf-8
{ number: 7, size: 500, holder: 'Daniel Price' }
The status, content type, and plot data match what curl showed, because the board doesn’t care which client asked. The script prints the parsed body as a JavaScript object instead of raw JSON. The board receives an HTTP request and sends an HTTP response, whether the request comes from a terminal or a script.
Sort Out Who Decided What
Every exchange you’ve made in this lesson has two halves, and each half has a different author.
Your side wrote the request. You chose the method, GET, and a path, such as /plots/7. Both curl and fetch() use GET by default. Either curl or fetch() added headers such as Host and User-Agent for you, and the body is empty in these requests. The board wrote the whole response, including the status code, the response headers, and the JSON body.
Here’s who wrote each part of an exchange with the board:
As a client, you’ve only ever controlled the first half. The board’s program controlled the second half. It read your path, looked up a plot, and decided between 200 and 404. It also decided that the body is JSON and set Content-Type to say so. A few headers, such as Date, come from Node.js itself rather than the board’s own code.
This course turns that around. You’ve received hundreds of responses. Now you’ll write the program that decides what goes into them.
Why does a missing plot get its own status code when the JSON body already explains the problem? It’s worth settling now, because soon you’ll be the one choosing the status code for every response. The button below opens a conversation with the AI mentor about it:
Before you move on, check that you can tell the two halves apart:
- In
curl -i http://localhost:3000/plots/99, which part did you choose, and which part did the board choose? - Why didn’t the terminal prompt come back after
npm start? - Your
fetch()script andcurlgot the same answer for plot 7. What does that tell you about how the board treats its clients?
- You chose the method,
GETby default, and the path/plots/99, andcurladded the request headers, such asHostandUser-Agent. The board chose the404 Not Foundstatus, theContent-Typeheader, and the JSON error body. - The board is a server. Instead of finishing and exiting, it keeps running, listening for requests and answering them until you stop it.
- The board only sees HTTP requests. It answers the same request in the same way, whichever program sent it.
When you’re done, go back to the board’s terminal and press Ctrl+C to stop it. The prompt comes back, and the board stops answering.
So far, you’ve treated the board as a black box that takes in requests and sends back responses. In the next lesson, Start Your Own Server, you’ll find out what kind of program sits on the other end. You’ll write the smallest server that answers every request, then start it and stop it yourself.