dev-resources.site
for different kinds of informations.
TIL: api route paths can be designed with the hypen (-) and the dot (.)
Published at
9/16/2024
Categories
study
web
api
backend
Author
dleedev365
Author
10 person written this
dleedev365
open
API routes can be designed to use the hypen and dot for useful purposes. For instance, to pass/parse multiple pieces of information.
Example usage of the hypen
Route path: /flights/:from-:to
Request URL: http://localhost:3000/flights/LAX-SFO
req.params: { "from": "LAX", "to": "SFO" }
Example usage of the dot
Route path: /plantae/:genus.:species
Request URL: http://localhost:3000/plantae/Prunus.persica
req.params: { "genus": "Prunus", "species": "persica" }
There're other ways to pass multiple values to a route path such that uses an array or the same parameter.
Example
Route path: /test
Request URL1: https://localhost:3000/test?array=a&array=b&array=c
Request URL2: https://localhost:3000/test?array[]=a&array[]=b&array[]=c
In the code
app.get('/test', function(req,res){
console.log(req.query.array); // array=[a,b,c]
res.send(200);
});
Note that query string exposes sensitive data to clients, so sensitive data shouldn't be put into a query string.
study Article's
30 articles in total
Let's build an app
read article
Day 2: Leetcode
read article
Career Boost: Cert IV Hospitality (SIT40416) RPL
read article
German Health Insurance for International Students: A Complete Guide
read article
Wi-Fi Components - 500-420 CAAPA Exam Guide
read article
Switching Packets - Cisco 010-151 DCTECH Exam Guide
read article
Wireless Interference - 500-301 CCS Exam
read article
Advantages and Disadvantages of Wi-Fi - 500-325 CSA Exam Guide
read article
What an IP Address Represents - Cisco 300-420 ENSLD Study Guide
read article
The Electromagnetic Spectrum - 500-425 CAAA Study Guide
read article
Computing a Global Address - Cisco 010-151 DCTECH Exam Guide
read article
Internet Protocol Version 4 - Cisco 300-420 ENSLD Study Guide
read article
Internet Protocol Version 6 - Cisco 300-430 ENWLSI Exam Guide
read article
Physical Addresses - Cisco 300-415 ENSDWI Study Guide
read article
Calculating Prefixes Using Skips - Cisco 300-425 ENWLSD Exam
read article
Microsoft 365 Active Directory - MS 900 Study Guide
read article
Why Two Addresses? - Cisco 300-425 ENWLSD Study Guide
read article
TIL: api route paths can be designed with the hypen (-) and the dot (.)
currently reading
Students Club Provides Study abroad Consultants in Faisalabad
read article
FAQ page in HTML only
read article
CompTIA A+ Study Guide Core 1 and Core 2 Exam Info
read article
Education Loan For Study Abraod
read article
The Biggest Difficulties Students Face When Deciding to Study Abroad
read article
Conch
read article
How to apply with MOI certificate at a UK University
read article
YES Germany: Your Go-To Study Abroad Consultant in Udaipur
read article
Assessment Help
read article
Adamjee notes for class 9 physics
read article
Study MBBS in Europe
read article
A Comprehensive Guide to Obtaining a UK Study Visa
read article
Featured ones: