Basics

What are HTTP methods — and why a Delete button must never be a link

Illustration: two doors — one labelled “view”, the other “change”

Back in 2005 Google shipped a browser accelerator. Handy idea: it opened the links on a page ahead of time, so the page would appear instantly later. And users of an app called Backpack started losing their notes.

Nobody was hacked. "Delete" in that app was just a link. The accelerator dutifully clicked every link on the page — including that one. It even sailed past the "Are you sure?" popup, because it never got that far.

The whole story comes down to one line in the request you never see. It's called the method.

A method is a promise, not a technical detail

Every time your browser goes to a server, it says two things: where (the address) and what it intends to do (the method). There are many methods; four will carry you:

  • GET — "show me." Open a page, fetch a list of products. Changes nothing.
  • POST — "here's something new." Submit a form, create an order.
  • PUT / PATCH — "change what's already there." Fully or partly.
  • DELETE — "remove it."

Here's the key: the server can physically do anything on any method. Nothing stops you writing code that wipes the database on a GET. A method isn't a lock — it's a promise you make to the entire internet.

And that promise isn't read by people. It's read by browsers, search crawlers, accelerators, email antivirus scanners, the Back button. All of them assume: a GET can be repeated any number of times and nothing will change.

What happened in 2005

Now the story assembles itself. The app promised "this is just a link" — while the link actually deleted data. The accelerator believed the promise and visited the links in advance.

From the accelerator's point of view it did nothing wrong: it opened a few pages. From the user's point of view, their notes vanished.

Why this is still about you

The accelerator is long gone. The rake is still in the grass.

  • Back button and refresh. A browser repeats a GET happily. Before repeating a POST it asks, "Resend data?" That's exactly why checkout is a POST — otherwise double-ordering pizza would be routine.
  • Email scanners. Corporate mail opens links from messages ahead of time to check them for malware. A link saying "Confirm account deletion" gets opened before a human ever sees it.
  • Search crawlers. A crawler only visits your site with GET, confident it can't break anything. If your delete lives on a GET, the crawler will find it.
  • The address is visible and it sticks around. Everything in a GET URL lands in browser history, server logs and analytics. Passwords and tokens can't live there.

How you set the method in code

There's a default trap here. A link is always GET — it has no method to set. And a plain HTML form defaults to GET too, which people forget:

<!-- ends up in the URL: /search?q=... and lands in history -->
<form action="/search">…</form>

<!-- correct for anything that changes something -->
<form action="/orders" method="post">…</form>

From code the method is explicit — and silence, again, means GET:

await fetch("/api/orders", {
  method: "POST",                                  // without this line it's a GET
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ item: "coffee" }),
});

Practical upshot: when a request "somehow doesn't save," first check whether it went out as a GET. A GET doesn't carry a request body at all.

The rule that settles everything

Remember one sentence: a GET changes nothing on the server.

Everything else follows:

  • A button that creates, changes or deletes is a form or a code request with POST/PUT/DELETE. Not a link.
  • A link (<a href>) is for "show me" only. Even with a confirmation next to it.
  • Want an action styled like a link? Fine — just don't let it be a GET underneath.

You can check yourself in a minute. Open your browser's developer tools, the Network tab, and click around your app. Each request shows its method. Spot a GET next to something that changes data, and you've found a future bug.

That same promise is what REST API design is built on: the method is the verb, the address is the noun. DELETE /orders/12 reads out loud and needs no explanation. If you're still getting comfortable with how apps talk to each other, start with what an API is.

How is PUT different from POST?

POST creates something new: send it twice, get two orders. PUT replaces one specific record entirely: send it twice, same result. That's why a PUT is safe to retry after a dropped connection and a POST isn't.

Why is site search a GET but the login form a POST?

Search results change nothing, and it's useful to bookmark them or send them to a friend — a URL carrying the query is exactly right. A password in the URL would settle into browser history and server logs, so login is always POST.

Does the method decide the response code?

No — they're separate: the method is what you ask for, the number in the response is how it went. There's a separate piece on the other half: HTTP status codes. And if a request from code returned something unexpected, see why fetch returns undefined.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →