Portugal’s holidays came back with HTTP/1.1 200 OK on the status line, and that 200 said the request worked. The planner will send many more requests than that one, for four friends in four countries, and not every answer will be a 200.
The status code is the first thing to read in any response. It tells you whether the request worked, and when it didn’t, whether the fix is yours or the server’s. In this lesson, you’ll sort any status code into its class, recognize this course’s codes by name, and decide who has to change something. Start with a request that can’t work.
Ask for a Country That Doesn’t Exist
The planner takes country codes from people, and people make typos. To see what a server says when the request itself is wrong, ask Nager.Date for the holidays of XX, which isn’t a country code:
$ curl --http1.1 -i https://date.nager.at/api/v4/Holidays/XX/2026
HTTP/1.1 404 Not Found
Date: Fri, 27 Nov 2026 13:20:03 GMT
Content-Type: application/json; charset=utf-8
...
{"title":"Unknown country code","status":404,"detail":"The
⮑ country code provided is invalid or not recognized."}
This output is from a real run on November 27, 2026, cut at the ... and wrapped at the ⮑ mark. The status line now reads 404 Not Found. The body is still JSON, but it describes the problem instead of listing holidays.
Notice who did their job here. The server is fine: it understood the request, looked for country XX, and reported that there’s no such thing.
Don’t mistake every failed request for a broken server. A 404 means the server found nothing at that path, or won’t reveal that something is there. Here the cause is in your request. XX isn’t a country code, so sending the same request again gets the same 404.
If that still feels fuzzy, ask the mentor. The button opens a chat with this question filled in:
Sort Codes by Their First Digit
You don’t need to memorize dozens of status codes. Their first digit puts each one in a status class, and the class alone tells you most of what happened. You can get the class in the Node REPL by dividing by 100 and dropping the remainder with Math.floor():
> Math.floor(404 / 100)
4
> Math.floor(503 / 100)
5
The five classes each have one meaning:
- 1xx, informational: An interim answer sent before the final response to the same request. curl and your JavaScript code handle these for you, so you won’t read them in this course.
- 2xx, success: The request worked, as Portugal’s
200did. - 3xx, redirection: The client has to take a further step, often following another URL. Ask Nager.Date over
http://instead ofhttps://, and it answers301 Moved Permanentlywith aLocationheader naming thehttps://address. curl follows that address only if you add its-Loption, whilefetch()follows it for you by default. - 4xx, client error: The request was wrong. The client, the program that sent the request, has to change something.
- 5xx, server error: The server failed while handling a request that may have been fine.
Decide Who Has to Act
The class tells you who has to act, and a handful of named codes tell you what to do. These are the ones you’ll meet in this course:
200 OK: Success, with the data in the body.201 Created: Success, and the server stored something new, such as the weekend the friends chose.204 No Content: Success, with no body at all.400 Bad Request: The server couldn’t make sense of the request. Nager.Date answers this when the year in the path isabcd.401 Unauthorized: The request lacks valid credentials. APIs that need a key answer this when it’s missing or wrong.403 Forbidden: The server understood the request but refuses it. A key without permission for this request is one example.404 Not Found: The server found nothing at that path, as withXX, or won’t reveal that something is there.429 Too Many Requests: You’ve sent too many requests, so slow down. ARetry-Afterheader may say how long to wait:Retry-After: 30means 30 seconds.500 Internal Server Error: Something went wrong inside the server.503 Service Unavailable: The server can’t answer right now, often because it’s overloaded or down for maintenance.
For a 4xx code, you change the request: fix the URL, add what’s missing, or get permission. The exception is 429. Your request was fine, but you need to wait and send fewer requests.
For a 5xx code, your request may be fine, and only the server can fix the problem. A 503 may clear if you wait and try again. You’ll handle retries and Retry-After later in the course, along with Cache-Control, the header from the last lesson that tells caches how long a response stays fresh.
A 401 and a 403 are the pair people mix up most. If you’d like to test yourself on them, ask the mentor for a few situations and say which code each one gets:
Check Your Reading
Use the classes and the named codes to answer these:
- You request
https://date.nager.at/api/v4/Holidays/PT/2026and receive503 Service Unavailable. Is the problem in your request or in the server, and could sending the same request again help? - You request the same path with
XXinstead ofPTand receive404 Not Found. Answer the same two questions. - The planner sends the friends’ chosen weekend to a server, which answers
201 Created. What’s the class, and did it work? - A server answers
429withRetry-After: 30. Who has to change something, and what?
- It’s a 5xx code, so the server failed. Your request may be fine, and trying again later could work.
- It’s a 4xx code, so your request was wrong:
XXisn’t a country code. The same request gets the same404every time. Fix the country code instead. - It’s in the 2xx class, so it worked, and the server stored the weekend.
- You do, even though your request was fine. Wait 30 seconds before you send another request, and send fewer requests.
The requests you sent with curl so far were all GET requests that it built for you. In the next lesson, Choose What a Request Needs, you’ll decide the method, URL, headers, and body of a request yourself.