Skip to content

ProfessorSolo/Node2Know-ExpressQueryStrings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node2Know — Express Query Strings

A minimal Express app demonstrating query strings with req.query.

Query strings are the “options panel” for a route:

  • they don’t change the route path
  • they modify the request using key/value pairs after ?

Example:

/search?keyword=turbo&sort=desc

✅ Prereqs

  • Node.js
  • npm

Check:

node -v
npm -v

📦 Install

npm install

▶️ Run

npm start

🧪 Try it

With keyword + sort

Open:

  • http://localhost:3000/search?keyword=turbo&sort=desc

You’ll get:

Searching for turbo sorted by desc

With keyword only

Open:

  • http://localhost:3000/search?keyword=turbo

You’ll get:

Searching for turbo sorted by undefined

(That’s intentional — it shows sort is optional unless you enforce it.)

Missing keyword

Open:

  • http://localhost:3000/search

You’ll get:

Please specify a keyword.

👀 Watch mode

npm run watch

Edit app.js, save, refresh.

Stop with:

  • Ctrl + C

🧠 Key idea

Query string values land here:

req.query

So:

  • /search?keyword=turbo&sort=desc
  • req.query = { keyword: "turbo", sort: "desc" }

📁 Project Structure

.
├── app.js
├── package.json
└── README.md

Repo


License

Node2Know-LEARN-1.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors