09 - Get Route Parameter Input from the Client - Basic Node and Express - freeCodeCamp Tutorial
Ganesh H
When building an API or Web App, we would need to capture Inputs in our requests. One way to do this is to extract parameters from the URL. We can specify these with colons (:) and they will be stored in the params object of the request.
Link to challenge : https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client Written Guide : https://www.notion.so/ganeshh123/Get-Route-Parameter-Input-from-the-Client-53fe0e57cdc54301b5bf6b62b1058814
Full Playlist for this course : https://www.youtube.com/playlist?list=PLhGp6N0DI_1SdIZ3uhbXnKAq2UcICSnWS All Writen Guides for this course : https://www.notion.so/ganeshh123/dab5e189407244c793c2f32d066eee9f All My Tutorials can be found at : https://www.notion.so/Tutorials-Ganesh-H-293ea420d34a464f9a1907e0405b5f26
Concepts: Route Parameters Route parameters are named URL segments that are used to capture the values specified at their position in the URL. The captured values are populated in the req.params object, with the name of the route parameter specified in the path as their respective keys. https://expressjs.com/en/guide/routing.html#route-parameters
request.params This property is an object containing properties mapped to the named route “parameters”. For example, if you have the route /user/:name, then the “name” property is available as req.params.name. This object defaults to {}. https://expressjs.com/en/api.html#req.params
Middleware Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. The next middleware function is commonly denoted by a variable named next. http://expressjs.com/en/guide/using-middleware.html
app.get() Routes HTTP GET requests to the specified path with the specified callback functions. https://expressjs.com/en/5x/api.html#app.get.method
response.json() Sends a JSON response. This method sends a response (with the correct content-type) that is the parameter converted to a JSON string using JSON.stringify(). The parameter can be any JSON type, including object, array, string, Boolean, number, or null, and you can also use it to convert other values to JSON. https://expressjs.com/en/api.html#res.json
-————————————————————————————————————- Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.
Express.js, or simply Express, is ... https://www.youtube.com/watch?v=QO9rzAPPCWk
19461596 Bytes