|
|
|
@ -147,10 +147,29 @@ Now inside the .ejs file, we can access `variable1Name` like so:
|
|
|
|
Value: <%= variable1Name; %>
|
|
|
|
Value: <%= variable1Name; %>
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Params/Query Strings
|
|
|
|
## URL Params/Query Strings
|
|
|
|
## REST
|
|
|
|
|
|
|
|
## Middleware
|
|
|
|
Data can be passed to the server through query strings (a.ka. GET parameters) which look like ?param1=value1¶m2=value2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
They can be accessed like so:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
|
|
app.get('/', function(req, res){
|
|
|
|
|
|
|
|
var param1 = req.query.param1;
|
|
|
|
|
|
|
|
var param2 = req.query.param2;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Your route can also have parameters in the path section
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
|
|
app.get('/:id', function(req, res){
|
|
|
|
|
|
|
|
var id = req.params.id;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Body Parser
|
|
|
|
## Body Parser
|
|
|
|
|
|
|
|
## REST
|
|
|
|
## Method Override
|
|
|
|
## Method Override
|
|
|
|
## Database
|
|
|
|
## Database
|
|
|
|
## Static
|
|
|
|
## Static
|
|
|
|
|