Rullst AcademyRullst Academy/Lesson
Applications with Rullst I · Lesson 10 / 14

Connect without losing context

The network may fail before or after a write.

Learning paths20 min

Let's discover together

  1. 1

    web/app.js uses fetch to list, create and complete. response.ok covers 200–299; fetch normally resolves its Promise even for 422 or 503. An error response must be checked, not mistaken for success just because it arrived.

  2. 2

    The form keeps the title when creation is not confirmed. After 201, it can clear it: creation was confirmed even if the following list refresh fails. busy blocks local double clicks; it does not prevent duplication by another client or a later repeated call.

  3. 3

    If the connection drops, the server may already have written and the response may be lost. The message therefore asks you to refresh before repeating POST. Creation has no automatic retry. Check this with a controlled lab failure, without affecting other services.

  4. 4

    Titles are inserted with textContent, not innerHTML. Enter <em>Orbit</em>: it should appear literally, not as markup. Safety depends on context; textContent suits node text, not every URL, CSS or other destination.

Your application workbench

The kit includes a complete app to investigate and modify. The excerpt below explains this step; the editor contains the indicated file. Rullst Academy does not compile or run this server in your browser.

File to study and modify

web/app.js

const response = await fetch("/api/missions");
if (!response.ok) throw Error("Request failed");
const items = await response.json();
text.textContent = item.title;

Extract the kit to a new folder and open a terminal beside Cargo.toml. Use Rust 1.96+; the first build may download dependencies and take time. Then open http://127.0.0.1:3010. Stop with Ctrl+C and run again after editing.

cargo test --locked
cargo run --locked
My files and GitHub

Download your draft and replace the indicated file in your extracted copy. The editor saves one file in this browser; your account saves assessments and XP. The ZIP excludes your edits. GitHub sends only the confirmed file; use Git manually for the whole app, excluding databases, backups and secrets.

Official links and next step

✦
YOUR MISSION

Handle HTTP responses and network failures while preserving user understanding.

Now it's your turn

Discovery workshop

Decide before running

Handle HTTP responses and network failures while preserving user understanding.
Build your answers and check when you are ready.
A moment to understand

How do you show a title containing <em> without interpreting HTML?

I need a hint

The title is text data. Choosing the right output API avoids turning it into executable markup.

Loading your journey…

Take it with you

Stop only your server and try submitting a fictional task. Check the message and preserved form. Restart, refresh and explain why a network failure alone cannot prove nothing was written.

At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.