Query String
ELI5 — The Vibe Check
A query string is the part of a URL after the question mark. It's how you pass extra information to a web server — like search terms, page numbers, or filters. 'google.com/search?q=cats' — everything after '?' is the query string: q=cats.
Real Talk
A query string is the portion of a URL beginning with '?' containing key-value pairs separated by '&'. It passes parameters to the server without affecting the resource path. Query strings are visible in the URL, logged by servers, and can be bookmarked.
Show Me The Code
// Parsing query strings
// URL: /products?category=shoes&size=10&color=red
// Express.js
app.get('/products', (req, res) => {
const { category, size, color } = req.query;
// category = 'shoes', size = '10', color = 'red'
});
// Vanilla JS
const params = new URLSearchParams(window.location.search);
const category = params.get('category'); // 'shoes'
When You'll Hear This
"Pass the search term as a query string parameter." / "Don't put sensitive data in the query string — it appears in logs."
Related Terms
Path Parameter
A path parameter is a variable embedded directly in the URL path. Instead of '?id=5', you put the value right in the path: '/users/5'.
Request
A request is what your browser (or app) sends to a server when it wants something. 'Give me the homepage.' 'Give me that image.
URI (Uniform Resource Identifier)
A URI is the general term for any identifier of a resource. URLs are URIs that tell you WHERE and HOW to get something.
URL (Uniform Resource Locator)
A URL is the complete web address of something on the internet — the full 'how to get there' including the protocol, domain, path, and any query parameters...