Skip to content

Beginner · What full-stack development is · topic 2 of 34 · 30 min

What happens when you tap Save

Explanation

When you tap Save in the Notes app, JavaScript builds a request, the browser finds the server with DNS, opens a secure HTTPS connection and sends the request. A server route checks it, runs an SQL query, and sends back a JSON response with a status code. The browser reads it and updates the screen. All this usually takes well under a second.

One tap, eight steps

Full-stack work is about connecting the layers, so you must know the whole path of one request. Let us follow a single tap on Save in our Notes app, from the finger to the database and back.

Think of it like this: Think of sending a parcel by courier. You write the address (the URL). The courier office looks up which depot serves that PIN code (DNS). The parcel goes in a sealed box that nobody on the way can open (HTTPS). At the depot, staff check the label and follow their rules (the server route). The item goes on the right warehouse shelf (the database). Finally you get a receipt with a tracking status (the response with a status code).
  1. The click: you tap Save. A JavaScript function in the frontend runs.
  2. JavaScript builds a request: method POST, address /api/notes, and the note as JSON in the body.
  3. DNS lookup: the browser turns the name (like notes.example.com) into an IP address, the number that identifies the server on the internet.
  4. HTTPS connection: the browser and server agree on encryption, so nobody in between (for example on public Wi-Fi) can read or change the data.
  5. The server route: the backend finds the code for "POST /api/notes", checks you are logged in and checks the title is valid.
  6. The SQL query: the backend runs an INSERT to store the note, and the database returns the new row.
  7. The JSON response: the server answers with a status code (201 Created) and the saved note as JSON.
  8. The screen updates: the frontend reads the JSON and adds the note to your list.

Steps 1 and 2: the click builds a request

JSON (JavaScript Object Notation) is a text format for data, written like a JavaScript object: { "title": "Exam dates" }. Both sides understand it, so the frontend and backend use it to talk. The browser function fetch sends the request.

javascript
async function saveNote(title, body) {
  const res = await fetch('/api/notes', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ title, body, pinned: false }),
  });
  const note = await res.json();
  return note;
}
The frontend side: build a POST request with a JSON body, then read the JSON answer.

Steps 3 and 4: finding the server and locking the line

DNS (Domain Name System) is like the contacts app on your phone: you tap a name, and it finds the number. Browsers and your internet provider remember recent answers, so this step is often instant. HTTPS is HTTP (the language of web requests) with encryption added. The padlock in the address bar means the connection is encrypted.

Steps 5 and 6: the server route and the SQL query

A route is a piece of backend code linked to one method and path. In Express (the Node.js backend library we use) it looks like this. You will write real routes in module 3; for now, just read it.

javascript
app.post('/api/notes', async (req, res) => {
  const title = (req.body.title ?? '').trim();
  if (title === '') {
    return res.status(400).json({ error: { code: 'VALIDATION_ERROR', message: 'Title is required' } });
  }
  const note = await db.insertNote(req.user.id, title, req.body.body ?? '');
  res.status(201).json(note);
});
The backend side: check the input, save it, answer 201 with the new note.
sql
INSERT INTO notes (user_id, title, body, pinned, created_at, updated_at)
VALUES (1, 'Exam dates', 'Maths on 12 March', 0, '2026-03-01 10:00', '2026-03-01 10:00');
Inside insertNote: the SQL that stores the note (real code uses placeholders, never pasted text).

Steps 7 and 8: the response and the screen

Every response starts with a status code: a three-digit number that says how it went. The first digit tells the group. You will meet these again and again.

CodeMeaningWhen the Notes app uses it
200 OKIt worked, here is the dataLoading your notes
201 CreatedA new thing was madeSaving a new note
400 Bad RequestYour input is wrongEmpty title
401 UnauthorizedYou are not logged inSession expired
404 Not FoundThat thing does not existOpening a deleted note
500 Internal Server ErrorThe server brokeA bug in the backend
Tip: Open your browser's DevTools (press F12), go to the Network tab and click Save on any site. You can see each request, its status code, how long it took and the JSON it returned. This is the most useful debugging tool a full-stack developer has.
Careful: Never trust the frontend alone. A user can open DevTools and send any request they like, so the backend must check login, ownership and input on every request, even if the frontend already checked.

Watch the lesson

What happens when you tap Save · 1/7

Tap Save -> ... -> note on screen

What really happens when you tap Save in the Notes app? Let us follow one request.

Prefer a video by a teacher? Find free videos on “what happens when you type a url in the browser dns https http request response explained” on YouTube ↗

In real life: Checking results on a college results site

You type your roll number and press Get result. JavaScript builds a request like GET /api/results?roll=21CS045. DNS finds the server, HTTPS protects your roll number on the way, and the backend route checks the roll number format. It runs an SQL query to find your marks and answers 200 with JSON such as { "name": "...", "marks": [...] }. If the roll number does not exist, it answers 404 and the page shows "Result not found". On results day, thousands of these journeys happen every second, which is why such sites sometimes slow down.

Practice (0/3 done)

Task 1 · Code · Javascript

Write parseRequest(method, url) that returns { method, path, query } (keys in that order). method must be upper case. path is the part after the domain, without the query string. query is a plain object of the query parameters, with their values decoded. Use the built-in URL class: new URL(url).pathname and new URL(url).searchParams.

Task 2 · Code · Javascript

The eight steps of a request are named: "click", "build request", "dns lookup", "https connection", "server route", "sql query", "json response", "screen update". Fill ORDER with these names in the correct order, then write orderSteps(steps) that returns a NEW array with the given steps sorted into the journey order. Do not change the input array.

Task 3 · Code · Javascript

Write statusGroup(code) that returns the group of an HTTP status code: "success" for 200-299, "redirect" for 300-399, "client error" for 400-499, "server error" for 500-599, and "unknown" for anything else.

Quick quiz

Question 1

1.What does DNS do?

Question 2

2.Why does the Notes app use HTTPS and not plain HTTP?

Question 3

3.A user saves a note and it is created. Which status code fits best?

Question 4

4.Where does the SQL query that stores the note run?

Question 5

5.Which browser tool lets you see every request, its status code and its JSON?

Read more (free)

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

← Previous: What full-stack means