Skip to content

Commit d49ceb2

Browse files
committed
content(blog): add post '5 Ways to Pass Arguments in a URL'
Fixes #1, #2, #3.
1 parent 7623cbb commit d49ceb2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# 5 Ways to Pass Arguments in a URL (Beyond the Basic Query)
2+
3+
When building web applications or designing APIs, understanding how to transfer data is crucial. While **Query Parameters** (the bits after the `?`) are the most common method, there are four other fundamental ways to pass arguments to a server via a URL or its associated HTTP request.
4+
5+
Here is a quick reference guide to the five main argument passing mechanisms:
6+
7+
## 1. Query Parameters
8+
9+
* **Location:** Appears in the URL after a **?** (question mark) and separated by **&** (ampersand) symbols.
10+
* **Purpose:** Used for **optional** parameters such as filtering, sorting, searching, or pagination controls.
11+
* **Characteristics:** Data is highly visible (in the URL, server logs, and browser history). It is typically used with **GET** requests.
12+
* **Example:** `https://example.com/products?**category=1&sort=price**`
13+
14+
## 2. Path Parameters
15+
16+
* **Location:** Directly integrated into the URL's path structure.
17+
* **Purpose:** Used to uniquely **identify a specific resource** or define a hierarchical location.
18+
* **Characteristics:** Essential for defining clear, clean, and meaningful URLs, especially in RESTful API design.
19+
* **Example:** `https://example.com/users/**123**` or `https://example.com/books/**sci-fi**/dune`
20+
21+
## 3. Header Parameters
22+
23+
* **Location:** Contained within the **HTTP Request Header**, invisible in the URL.
24+
* **Purpose:** Used for **metadata** about the request, such as authentication (e.g., API keys, tokens), content type, and language preferences.
25+
* **Characteristics:** Offers better security for sensitive, non-data payload information compared to Query Parameters, as it doesn't appear in the URL.
26+
* **Example:** `Header: **Authorization: Bearer token**` or `Header: **Content-Type: application/json**`
27+
28+
## 4. Fragment Identifier Arguments
29+
30+
* **Location:** Appears at the very end of the URL after a **#** (hash symbol).
31+
* **Purpose:** Used for client-side functionality, like navigating to a specific section (anchor) on a page or managing application state in Single Page Applications (SPAs).
32+
* **Characteristics:** The browser **does NOT send this part to the server**; it is client-side only. It can still be used to pass data to the front-end application.
33+
* **Example:** `https://example.com/page**#section-name**`
34+
35+
## 5. Request Body Arguments
36+
37+
* **Location:** Contained within the **body** (payload) of the HTTP request, invisible in the URL.
38+
* **Purpose:** Used for sending large data payloads when creating or updating resources (e.g., submitting a complex form, uploading a file, or sending a JSON object).
39+
* **Characteristics:** The primary method for data submission using **POST, PUT, or PATCH** HTTP methods. It is an HTTP request argument, not a true URL argument, and it is secure from URL exposure.
40+
* **Example:** *(Data like a user object in JSON format is sent in the hidden body payload.)*
41+
42+
---
43+
44+
## Conclusion
45+
46+
By strategically selecting among Query, Path, Header, Fragment, or Body arguments, developers can ensure their data is transferred efficiently and securely, leading to a robust and scalable application architecture.

public/posts/posts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
[
2+
{
3+
"slug": "5-ways-to-pass-arguments-in-a-url",
4+
"title": "5 Ways to Pass Arguments in a URL (Beyond the Basic Query)",
5+
"date": "2025-12-24",
6+
"updated": "2025-12-24",
7+
"description": "A quick reference guide to the five main argument passing mechanisms in URLs and HTTP requests.",
8+
"tags": ["gist", "http", "api", "url", "webdev"],
9+
"category": "gist",
10+
"filename": "5-ways-to-pass-arguments-in-a-url.txt",
11+
"authors": ["fezcode"],
12+
"image": "/images/defaults/sina-salehian-HqmTUJD73mM-unsplash.jpg"
13+
},
214
{
315
"slug": "renaming-js-to-jsx-gist",
416
"title": "Quick Renaming .js to .jsx for React",

0 commit comments

Comments
 (0)